2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
6 * @file LArElecCalib/LArVectorProxy.icc
7 * @author scott snyder <snyder@bnl.gov>
9 * @brief Proxy for accessing a range of float values like a vector.
17 * @brief Default constructor.
18 * Creates the proxy in an invalid state.
21 LArVectorProxy::LArVectorProxy()
22 : std::span<const float>() {}
26 * @brief Construct a proxy referencing an existing vector.
27 * @param vec The existing vector to reference.
30 LArVectorProxy::LArVectorProxy (const std::vector<value_type>& vec)
31 : std::span<const float>(vec.cbegin(),vec.cend())
37 * @brief Construct a proxy referencing a range of vectors in memory.
38 * @param beg Pointer to the start of the range.
39 * @param end Pointer to the (exclusive) end of the range.
42 LArVectorProxy::LArVectorProxy (const value_type* beg, const value_type* end)
43 : std::span<const float>(beg,end)
49 * @brief Test to see if the proxy has been initialized.
52 bool LArVectorProxy::valid() const
54 return data() != nullptr;
59 * @brief Vector indexing with bounds check.
62 LArVectorProxy::value_type LArVectorProxy::at (size_t i) const
65 throw std::out_of_range ("LArVectorProxy::at");
71 * @brief Convert back to a vector.
74 std::vector<LArVectorProxy::value_type> LArVectorProxy::asVector() const
76 return std::vector<value_type> (begin(), end());