42 #ifndef UTIL_FOREACH_H 43 #define UTIL_FOREACH_H 56 using lib::meta::disable_if;
67 template <
typename IT,
typename FUN>
83 template <
typename IT,
typename FUN>
108 template <
typename Container
111 inline disable_if< can_IterForEach<Container>,
115 using lib::meta::unwrap;
117 return std::for_each (unwrap(coll).begin()
124 template <
typename IT
127 inline enable_if< can_IterForEach<IT>,
131 return std::for_each (ii, IT(), doIt);
137 template <
typename Container
140 inline enable_if< can_STL_ForEach<Container>,
142 and_all (Container
const& coll, FUN predicate)
144 using lib::meta::unwrap;
146 return and_all (unwrap(coll).begin()
152 template <
typename IT
155 inline enable_if< can_IterForEach<IT>,
157 and_all (IT
const& ii, FUN predicate)
159 return and_all (ii, IT(), predicate);
164 template <
typename Container
167 inline enable_if< can_STL_ForEach<Container>,
169 has_any (Container
const& coll, FUN predicate)
171 using lib::meta::unwrap;
173 return has_any (unwrap(coll).begin()
179 template <
typename IT
182 inline enable_if< can_IterForEach<IT>,
184 has_any (IT
const& ii, FUN predicate)
186 return has_any (ii, IT(), predicate);
197 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
201 for_each (elements, std::bind (
function, std::forward<P1>(bind1), std::forward<ARGS> (args)...));
210 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
214 return and_all (elements, std::bind<bool> (
function, std::forward<P1>(bind1), std::forward<ARGS> (args)...));
223 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
227 return has_any (elements, std::bind<bool> (
function, std::forward<P1>(bind1), std::forward<ARGS> (args)...));
IterQueue< T > elements(T const &elm)
convenience free function to build an iterable sequence
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
disable_if< can_IterForEach< Container >, FUN > for_each(Container const &coll, FUN doIt)
operate on all elements of a STL container.
Helpers for type detection, type rewriting and metaprogramming.
bool has_any(IT i, IT end, FUN predicate)
Existential quantification: check if any element of a collection satisfies the given predicate...
bool and_all(IT i, IT end, FUN predicate)
All quantification: check if all elements of a collection satisfy the given predicate.