82 #ifndef LARDATA_UTILITIES_COLLECTIONVIEW_H 83 #define LARDATA_UTILITIES_COLLECTIONVIEW_H 90 #include <type_traits> 95 template <
typename Range>
101 template <
typename Range>
115 using begin_iterator_t = std::decay_t<decltype(traits_t::getCBegin(std::declval<range_t>()))>;
116 using end_iterator_t = std::decay_t<decltype(traits_t::getCEnd(std::declval<range_t>()))>;
121 template <
typename BeginIter,
typename EndIter = BeginIter>
146 template <
typename BeginIter,
typename EndIter>
154 template <
typename Range>
164 template <
typename Range>
284 template <
typename Range>
333 return cend(asRange());
363 auto back() const -> decltype(auto) {
return *crbegin(); }
377 throw std::out_of_range(
"CollectionView index out of range: " +
std::to_string(i) +
380 return operator[](i);
412 friend this_t details::makeCollectionView<range_t>(
range_t&&);
422 template <
typename Range>
430 template <
typename BeginIter,
typename EndIter>
437 template <
typename BeginIter,
typename EndIter = BeginIter>
443 template <
typename Range>
453 #endif // LARDATA_UTILITIES_COLLECTIONVIEW_H 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
auto at(size_type i) const -> decltype(auto)
Returns the content of the i-th element.
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
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.
decltype(makeCollectionView(std::declval< BeginIter >(), std::declval< EndIter >())) RangeAsCollection_t
Type of collection view owning the two range boundary iterators.
CollectionView(range_t &&range)
Constructor: steals the data from the specified range.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
BeginIter begin_iterator_t
CollectionView< Range > makeCollectionView(Range &&)
Class storing a begin and a end iterator.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
auto front() const -> decltype(auto)
Returns the first element in the collection.
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.
auto operator[](size_type i) const -> decltype(auto)
Returns the content of the i-th element.
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.
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.