10 #ifndef LARCOREALG_COREUTILS_SPAN_H 11 #define LARCOREALG_COREUTILS_SPAN_H 14 #include "boost/iterator/transform_iterator.hpp" 19 #include <type_traits> 29 template <
typename Cont>
34 template <
typename Cont>
39 template <
typename Cont>
41 = std::decay_t<decltype(get_begin(std::declval<Cont>()))>;
44 template <
typename Cont>
46 = std::decay_t<decltype(get_end(std::declval<Cont>()))>;
50 template <
typename Cont>
55 template <
typename Cont>
60 template <
typename Cont>
62 = std::decay_t<decltype(get_cbegin(std::declval<Cont>()))>;
65 template <
typename Cont>
67 = std::decay_t<decltype(get_cend(std::declval<Cont>()))>;
124 template <
typename BIter,
typename EIter = BIter>
134 using pair_t = std::pair<begin_iterator, end_iterator>;
146 template <
typename SrcIterB,
typename SrcIterE,
typename Adaptor>
147 span(SrcIterB&&
b, SrcIterE&&
e, Adaptor&& adaptor)
149 (adaptor(
std::forward<SrcIterB>(
b)), adaptor(
std::forward<SrcIterE>(
e)))
153 template <
typename OBIter,
typename OEIter>
178 template <
typename IterB,
typename IterE,
typename Adaptor>
179 span(IterB&&
b, IterE&&
e, Adaptor&& adaptor)
181 #if 0 // this is C++17... 182 std::invoke_result_t<Adaptor, IterB>,
183 std::invoke_result_t<Adaptor, IterE>
184 #else // ... and this is what Clang 5.0 undestands 185 decltype(adaptor(std::forward<IterB>(
b))),
186 decltype(adaptor(std::forward<IterE>(
e)))
196 template <
typename BIter,
typename EIter>
200 template <
typename Cont>
205 template <
typename Cont>
222 template <
typename BIter,
typename EIter,
typename Adaptor>
224 {
return util::span(adaptor(begin), adaptor(end)); }
257 template <
typename Cont,
typename Adaptor>
262 std::forward<Adaptor>(adaptor)
268 template <
typename Cont,
typename Adaptor>
273 std::forward<Adaptor>(adaptor)
293 template <
typename BIter,
typename EIter,
typename Op>
297 = [&op](
auto iter){
return boost::make_transform_iterator(iter, op); };
340 template <
typename Cont,
typename Op>
352 template <
typename Cont,
typename Op>
363 #endif // LARCOREALG_COREUTILS_SPAN_H end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
Namespace for general, non-LArSoft-specific utilities.
bool empty() const
Returns whether the span is empty (that is, no steps between them).
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
span(begin_iterator b, end_iterator e)
Constructor: specifies the begin and end iterator.
span(SrcIterB &&b, SrcIterE &&e, Adaptor &&adaptor)
Constructor: specifies the begin and end iterator and an adapter.
static decltype(auto) get_begin(Cont &cont)
Returns the begin iterator of the specified container.
auto make_span(BIter begin, EIter end)
Creates a span from specified iterators (can use constructor instead).
std::decay_t< decltype(get_end(std::declval< Cont >()))> get_end_iterator
Type of end iterator of Cont type.
typename begin_iterator::value_type value_type
Type of values pointed by the iterators.
end_iterator end() const
Returns a copy of the end iterator.
Simple class with a begin and an end.
auto make_adapted_span(BIter begin, EIter end, Adaptor &&adaptor)
Iter end_iterator
Type of end iterator.
span(span< OBIter, OEIter > const &from)
Constructor: copies from another span (possibly with different types).
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
static decltype(auto) get_cbegin(Cont &cont)
Returns the constant begin iterator of the specified container.
static decltype(auto) get_cend(Cont &cont)
Returns the constant end iterator of the specified container.
Iter begin_iterator
Type of begin iterator.
auto make_transformed_const_span(Cont &cont, Op &&op)
std::decay_t< decltype(get_cbegin(std::declval< Cont >()))> get_cbegin_iterator
Type of constant begin iterator of Cont type.
auto make_transformed_span(BIter begin, EIter end, Op &&op)
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static decltype(auto) get_end(Cont &cont)
Returns the end iterator of the specified container.
std::size_t size() const
Returns the size between begin and end, converted to std::size_t.
typename begin_iterator::reference reference
Type of reference pointed by the iterators.
begin_iterator begin() const
Returns a copy of the begin iterator.
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
std::pair< begin_iterator, end_iterator > pair_t
Type of iterator pair.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
second_as<> second
Type of time stored in seconds, in double precision.
Non-templated base class for span.
std::decay_t< decltype(get_begin(std::declval< Cont >()))> get_begin_iterator
Type of begin iterator of Cont type.
std::decay_t< decltype(get_cend(std::declval< Cont >()))> get_cend_iterator
Type of constant end iterator of Cont type.
auto make_const_span(Cont &cont)
Creates a span with constant iterator access from a container type.
auto make_adapted_const_span(Cont &cont, Adaptor &&adaptor)
Creates constant iteration span from specified collection via an adaptor.