/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(FUSION_REPLACE_IF_08182005_0946) #define FUSION_REPLACE_IF_08182005_0946 #include #include #include #include namespace boost { namespace fusion { namespace detail { template struct replacer_if_helper; template <> struct replacer_if_helper { template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static U& call(U& x, F&, T const&) { return x; } }; template <> struct replacer_if_helper { template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static U call(U& x, F& f, T const& new_value) { return f(x) ? new_value : x; } }; template struct replacer_if { BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED replacer_if(F in_f, T const& in_new_value) : f(in_f), new_value(in_new_value) {} template struct result; template struct result(U)> { typedef typename remove_reference::type value; typedef typename mpl::if_, value, value const&>::type type; }; template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED typename result::type operator()(U const& x) const { return replacer_if_helper::value>:: call(x, f, new_value); } F f; T new_value; }; }}} #endif