82 #ifndef LARDATA_UTILITIES_COLLECTIONVIEW_H 83 #define LARDATA_UTILITIES_COLLECTIONVIEW_H 90 #include <type_traits> 97 template <
typename Range>
104 template <
typename Range>
113 = std::decay_t<decltype(traits_t::getCBegin(std::declval<range_t>()))>;
115 = std::decay_t<decltype(traits_t::getCEnd(std::declval<range_t>()))>;
121 template <
typename BeginIter,
typename EndIter = BeginIter>
148 template <
typename BeginIter,
typename EndIter>
154 template <
typename Range>
164 template <
typename Range>
285 template <
typename Range>
360 auto back()
const -> decltype(auto) {
return *crbegin(); }
375 throw std::out_of_range(
376 "CollectionView index out of range: " 380 return operator[](i);
399 CollectionViewWrapper() = default;
400 CollectionViewWrapper(this_t const&) = default;
401 CollectionViewWrapper(this_t&&) = default;
402 CollectionViewWrapper& operator=(this_t const&) = default;
403 CollectionViewWrapper& operator=(this_t&&) = default;
412 friend this_t details::makeCollectionView<range_t>(
range_t&&);
424 template <
typename Range>
431 template <
typename BeginIter,
typename EndIter>
438 template <
typename BeginIter,
typename EndIter = BeginIter>
445 template <
typename Range>
454 #endif // LARDATA_UTILITIES_COLLECTIONVIEW_H auto at(size_type i) const -> decltype(auto)
Returns the content of the i-th element.
Provides features of a collections, from begin and end iterators.
auto makeCollectionExtremes(BeginIter const &b, EndIter const &e)
Helper to create a CollectionExtremes object from two iterators.
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
typename iter_traits_t::reference const_reference
end_iter_t cend() const noexcept
Returns an iterator past the end of the collection.
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the begin of the collection.
std::decay_t< decltype(traits_t::getCBegin(std::declval< range_t >()))> begin_iterator_t
range_t collection_type
Type of collection being wrapped.
typename iter_traits_t::value_type value_type
decltype(makeCollectionView(std::declval< BeginIter >(), std::declval< EndIter >())) RangeAsCollection_t
Type of collection view owning the two range boundary iterators.
const_iterator cbegin() const noexcept
Returns an iterator to the begin of the collection.
const_iterator begin() const noexcept
Returns an iterator to the begin of the collection.
begin_iterator_t b
Stored copy of begin iterator.
typename iter_traits_t::difference_type difference_type
typename traits_t::end_iterator_t end_iter_t
Type of the end iterator.
CollectionExtremes(BeginIter b, EndIter e)
Constructor: copies the specified iterators.
end_iterator_t const & end() const
Returns the stored end iterator.
BoundaryListRangeBase< BoundaryIter > range_t
Type of the range being wrapped.
CollectionView(range_t &&range)
Constructor: steals the data from the specified range.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
CollectionView< Range > makeCollectionView(Range &&)
Class storing a begin and a end iterator.
auto front() const -> decltype(auto)
Returns the first element in the collection.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
size_type size() const noexcept
Returns the size of the collection.
range_t const & asRange() const
Returns this very object, cast back to range_t.
std::reverse_iterator< const_iterator > const_reverse_iterator
typename traits_t::begin_iterator_t begin_iter_t
Type of the begin iterator.
LArSoft-specific namespace.
begin_iterator_t const & begin() const
Returns the stored begin iterator.
std::iterator_traits< begin_iter_t > iter_traits_t
Type of traits of iterator.
auto back() const -> decltype(auto)
Returns the last element in the collection.
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the begin of the collection.
static auto getCEnd(range_t const &range)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
const_reverse_iterator crend() const noexcept
Returns a reverse iterator past the end of the collection.
typename iter_traits_t::pointer const_pointer
begin_iter_t const_iterator
end_iter_t end() const noexcept
Returns an iterator past the end of the collection.
const_reverse_iterator rend() const noexcept
Returns a reverse iterator past the end of the collection.
std::string to_string(ModuleType const mt)
end_iterator_t e
Stored copy of end iterator.
CollectionView< Range > const & wrapCollectionIntoView(Range const &c)
Returns the specified container, wrapped in the view.
std::decay_t< decltype(traits_t::getCEnd(std::declval< range_t >()))> end_iterator_t
const_pointer data() const
static auto getCBegin(range_t const &range)
bool empty() const noexcept
Returns whether the collection is empty.