]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ==============================================================================*/ | |
7 | #if !defined(FUSION_REPLACE_IF_08182005_0939) | |
8 | #define FUSION_REPLACE_IF_08182005_0939 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/view/transform_view/transform_view.hpp> | |
12 | #include <boost/fusion/algorithm/transformation/detail/replace_if.hpp> | |
13 | #include <boost/fusion/support/is_sequence.hpp> | |
14 | #include <boost/utility/enable_if.hpp> | |
15 | #include <boost/type_traits/is_same.hpp> | |
16 | ||
17 | namespace boost { namespace fusion | |
18 | { | |
19 | namespace result_of | |
20 | { | |
21 | template <typename Sequence, typename F, typename T> | |
22 | struct replace_if | |
23 | { | |
24 | typedef transform_view<Sequence, detail::replacer_if<F, T> > type; | |
25 | }; | |
26 | } | |
27 | ||
28 | template <typename Sequence, typename F, typename T> | |
29 | BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
30 | inline typename | |
31 | enable_if< | |
32 | traits::is_sequence<Sequence> | |
33 | , typename result_of::replace_if<Sequence const, F, T>::type | |
34 | >::type | |
35 | replace_if(Sequence const& seq, F pred, T const& new_value) | |
36 | { | |
37 | typedef typename result_of::replace_if<Sequence const, F, T>::type result; | |
38 | detail::replacer_if<F, T> f(pred, new_value); | |
39 | return result(seq, f); | |
40 | } | |
41 | }} | |
42 | ||
43 | #endif | |
44 |