3 Forward declares `boost::hana::while_`.
5 @copyright Louis Dionne 2013-2017
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)
10 #ifndef BOOST_HANA_FWD_WHILE_HPP
11 #define BOOST_HANA_FWD_WHILE_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Apply a function to an initial state while some predicate is satisfied.
19 //! @ingroup group-Logical
21 //! This method is a natural extension of the `while` language construct
22 //! to manipulate a state whose type may change from one iteration to
23 //! another. However, note that having a state whose type changes from
24 //! one iteration to the other is only possible as long as the predicate
25 //! returns a `Logical` whose truth value is known at compile-time.
27 //! Specifically, `while_(pred, state, f)` is equivalent to
31 //! where `f` is iterated as long as `pred(f(...))` is a true-valued
36 //! A predicate called on the state or on the result of applying `f` a
37 //! certain number of times to the state, and returning whether `f`
38 //! should be applied one more time.
41 //! The initial state on which `f` is applied.
44 //! A function that is iterated on the initial state. Note that the
45 //! return type of `f` may change from one iteration to the other,
46 //! but only while `pred` returns a compile-time `Logical`. In other
47 //! words, `decltype(f(stateN))` may differ from `decltype(f(stateN+1))`,
48 //! but only if `pred(f(stateN))` returns a compile-time `Logical`.
53 //! @include example/while.cpp
54 #ifdef BOOST_HANA_DOXYGEN_INVOKED
55 constexpr auto while_ = [](auto&& pred, auto&& state, auto&& f) -> decltype(auto) {
56 return tag-dispatched;
59 template <typename L, typename = void>
60 struct while_impl : while_impl<L, when<true>> { };
63 template <typename Pred, typename State, typename F>
64 constexpr decltype(auto) operator()(Pred&& pred, State&& state, F&& f) const;
67 constexpr while_t while_{};
69 BOOST_HANA_NAMESPACE_END
71 #endif // !BOOST_HANA_FWD_WHILE_HPP