]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::replace`. | |
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_REPLACE_HPP | |
11 | #define BOOST_HANA_FWD_REPLACE_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 that compare equal | |
19 | //! to some `value` with some new fixed value. | |
20 | //! @ingroup group-Functor | |
21 | //! | |
22 | //! | |
23 | //! Signature | |
24 | //! --------- | |
25 | //! Given `F` a Functor and `U` a type that can be compared with `T`, | |
26 | //! the signature is | |
27 | //! \f$ | |
28 | //! \mathtt{replace} : F(T) \times U \times T \to F(T) | |
29 | //! \f$ | |
30 | //! | |
31 | //! @param xs | |
32 | //! The structure to replace elements of. | |
33 | //! | |
34 | //! @param oldval | |
35 | //! An object compared with each element of the structure. Elements | |
36 | //! of the structure that compare equal to `oldval` are replaced | |
37 | //! by `newval` in the new structure. | |
38 | //! | |
39 | //! @param newval | |
40 | //! A value by which every element `x` of the structure that compares | |
41 | //! equal to `oldval` is replaced. | |
42 | //! | |
43 | //! | |
44 | //! Example | |
45 | //! ------- | |
46 | //! @include example/replace.cpp | |
47 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
48 | constexpr auto replace = [](auto&& xs, auto&& oldval, auto&& newval) { | |
49 | return tag-dispatched; | |
50 | }; | |
51 | #else | |
52 | template <typename Xs, typename = void> | |
53 | struct replace_impl : replace_impl<Xs, when<true>> { }; | |
54 | ||
55 | struct replace_t { | |
56 | template <typename Xs, typename OldVal, typename NewVal> | |
57 | constexpr auto operator()(Xs&& xs, OldVal&& oldval, NewVal&& newval) const; | |
58 | }; | |
59 | ||
60 | constexpr replace_t replace{}; | |
61 | #endif | |
62 | BOOST_HANA_NAMESPACE_END | |
63 | ||
64 | #endif // !BOOST_HANA_FWD_REPLACE_HPP |