3 Forward declares `boost::hana::adjust_if`.
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)
10 #ifndef BOOST_HANA_FWD_ADJUST_IF_HPP
11 #define BOOST_HANA_FWD_ADJUST_IF_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Apply a function on all the elements of a structure satisfying a predicate.
19 //! @ingroup group-Functor
21 //! Given a Functor, a predicate `pred` and a function `f`, `adjust_if`
22 //! will _adjust_ the elements of the Functor that satisfy the predicate
23 //! with the function `f`. In other words, `adjust_if` will return a new
24 //! Functor equal to the original one, except that the elements satisfying
25 //! the predicate will be transformed with the given function. Elements
26 //! for which the predicate is not satisfied are left untouched, and they
27 //! are kept as-is in the resulting Functor.
32 //! Given a `Functor` `F` and a `Logical` `Bool`, the signature is
34 //! \mathtt{adjust_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T)
38 //! The structure to adjust with `f`.
41 //! A function called as `pred(x)` for each element of the Functor,
42 //! and returning whether `f` should be applied on that element.
45 //! A function called as `f(x)` on the element(s) of the Functor that
46 //! satisfy the predicate.
51 //! @include example/adjust_if.cpp
52 #ifdef BOOST_HANA_DOXYGEN_INVOKED
53 constexpr auto adjust_if = [](auto&& xs, auto const& pred, auto const& f) {
54 return tag-dispatched;
57 template <typename Xs, typename = void>
58 struct adjust_if_impl : adjust_if_impl<Xs, when<true>> { };
61 template <typename Xs, typename Pred, typename F>
62 constexpr auto operator()(Xs&& xs, Pred const& pred, F const& f) const;
65 constexpr adjust_if_t adjust_if{};
67 BOOST_HANA_NAMESPACE_END
69 #endif // !BOOST_HANA_FWD_ADJUST_IF_HPP