]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/hana/fwd/replace_if.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / hana / fwd / replace_if.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::replace_if`.
4
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)
8 */
9
10 #ifndef BOOST_HANA_FWD_REPLACE_IF_HPP
11 #define BOOST_HANA_FWD_REPLACE_IF_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Replace all the elements of a structure satisfying a `predicate`
19 //! with a fixed value.
20 //! @ingroup group-Functor
21 //!
22 //!
23 //! Signature
24 //! ---------
25 //! Given `F` a Functor and `Bool` a Logical, the signature is
26 //! \f$
27 //! \mathtt{replace\_if} : F(T) \times (T \to Bool) \times T \to F(T)
28 //! \f$
29 //!
30 //! @param xs
31 //! The structure to replace elements of.
32 //!
33 //! @param predicate
34 //! A function called as `predicate(x)` for element(s) `x` of the
35 //! structure and returning a `Logical` representing whether `x`
36 //! should be replaced by `value`.
37 //!
38 //! @param value
39 //! A value by which every element `x` of the structure for which
40 //! `predicate` returns a true-valued `Logical` is replaced.
41 //!
42 //!
43 //! Example
44 //! -------
45 //! @include example/replace_if.cpp
46 #ifdef BOOST_HANA_DOXYGEN_INVOKED
47 constexpr auto replace_if = [](auto&& xs, auto&& predicate, auto&& value) {
48 return tag-dispatched;
49 };
50 #else
51 template <typename Xs, typename = void>
52 struct replace_if_impl : replace_if_impl<Xs, when<true>> { };
53
54 struct replace_if_t {
55 template <typename Xs, typename Pred, typename Value>
56 constexpr auto operator()(Xs&& xs, Pred&& pred, Value&& value) const;
57 };
58
59 constexpr replace_if_t replace_if{};
60 #endif
61 BOOST_HANA_NAMESPACE_END
62
63 #endif // !BOOST_HANA_FWD_REPLACE_IF_HPP