]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/fwd/adjust_if.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / adjust_if.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::adjust_if`.
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_ADJUST_IF_HPP
11 #define BOOST_HANA_FWD_ADJUST_IF_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Apply a function on all the elements of a structure satisfying a predicate.
19 //! @ingroup group-Functor
20 //!
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.
28 //!
29 //!
30 //! Signature
31 //! ---------
32 //! Given a `Functor` `F` and a `Logical` `Bool`, the signature is
33 //! \f$
34 //! \mathtt{adjust_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T)
35 //! \f$
36 //!
37 //! @param xs
38 //! The structure to adjust with `f`.
39 //!
40 //! @param pred
41 //! A function called as `pred(x)` for each element of the Functor,
42 //! and returning whether `f` should be applied on that element.
43 //!
44 //! @param f
45 //! A function called as `f(x)` on the element(s) of the Functor that
46 //! satisfy the predicate.
47 //!
48 //!
49 //! Example
50 //! -------
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;
55 };
56 #else
57 template <typename Xs, typename = void>
58 struct adjust_if_impl : adjust_if_impl<Xs, when<true>> { };
59
60 struct adjust_if_t {
61 template <typename Xs, typename Pred, typename F>
62 constexpr auto operator()(Xs&& xs, Pred const& pred, F const& f) const;
63 };
64
65 constexpr adjust_if_t adjust_if{};
66 #endif
67 BOOST_HANA_NAMESPACE_END
68
69 #endif // !BOOST_HANA_FWD_ADJUST_IF_HPP