51 #ifndef UTIL_FOREACH_H 52 #define UTIL_FOREACH_H 65 using lib::meta::disable_if;
76 template <
typename IT,
typename FUN>
92 template <
typename IT,
typename FUN>
117 template <
typename Container
120 inline disable_if< can_IterForEach<Container>,
124 using lib::meta::unwrap;
126 return std::for_each (unwrap(coll).begin()
133 template <
typename IT
136 inline enable_if< can_IterForEach<IT>,
140 return std::for_each (ii, IT(), doIt);
146 template <
typename Container
149 inline enable_if< can_STL_ForEach<Container>,
151 and_all (Container
const& coll, FUN predicate)
153 using lib::meta::unwrap;
155 return and_all (unwrap(coll).begin()
161 template <
typename IT
164 inline enable_if< can_IterForEach<IT>,
166 and_all (IT
const& ii, FUN predicate)
168 return and_all (ii, IT(), predicate);
173 template <
typename Container
176 inline enable_if< can_STL_ForEach<Container>,
178 has_any (Container
const& coll, FUN predicate)
180 using lib::meta::unwrap;
182 return has_any (unwrap(coll).begin()
188 template <
typename IT
191 inline enable_if< can_IterForEach<IT>,
193 has_any (IT
const& ii, FUN predicate)
195 return has_any (ii, IT(), predicate);
206 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
210 for_each (elements, std::bind (
function, std::forward<P1>(bind1), std::forward<ARGS> (args)...));
219 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
223 return and_all (elements, std::bind<bool> (
function, std::forward<P1>(bind1), std::forward<ARGS> (args)...));
232 template <
typename CON,
typename FUN,
typename P1,
typename...ARGS>
236 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.