]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::for_each`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_FWD_FOR_EACH_HPP | |
11 | #define BOOST_HANA_FWD_FOR_EACH_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Perform an action on each element of a foldable, discarding | |
19 | //! the result each time. | |
20 | //! @ingroup group-Foldable | |
21 | //! | |
22 | //! Iteration is done from left to right, i.e. in the same order as when | |
23 | //! using `fold_left`. If the structure is not finite, this method will | |
24 | //! not terminate. | |
25 | //! | |
26 | //! | |
27 | //! @param xs | |
28 | //! The structure to iterate over. | |
29 | //! | |
30 | //! @param f | |
31 | //! A function called as `f(x)` for each element `x` of the structure. | |
32 | //! The result of `f(x)`, whatever it is, is ignored. | |
33 | //! | |
34 | //! | |
35 | //! Example | |
36 | //! ------- | |
37 | //! @include example/for_each.cpp | |
38 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
39 | constexpr auto for_each = [](auto&& xs, auto&& f) -> void { | |
40 | tag-dispatched; | |
41 | }; | |
42 | #else | |
43 | template <typename T, typename = void> | |
44 | struct for_each_impl : for_each_impl<T, when<true>> { }; | |
45 | ||
46 | struct for_each_t { | |
47 | template <typename Xs, typename F> | |
48 | constexpr void operator()(Xs&& xs, F&& f) const; | |
49 | }; | |
50 | ||
51 | constexpr for_each_t for_each{}; | |
52 | #endif | |
53 | BOOST_HANA_NAMESPACE_END | |
54 | ||
55 | #endif // !BOOST_HANA_FWD_FOR_EACH_HPP |