mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-20 15:52:13 +02:00
fusion fold and transform passing refs for lvalues as per result_of protocol
[SVN r38039]
This commit is contained in:
@ -13,6 +13,9 @@
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
namespace result_of
|
||||
{
|
||||
@ -32,8 +35,11 @@ namespace detail
|
||||
|
||||
template <typename Iterator, typename State, typename F>
|
||||
struct fold_apply
|
||||
: boost::result_of<F(typename result_of::value_of<Iterator>::type, State)>
|
||||
{};
|
||||
{
|
||||
typedef typename result_of::deref<Iterator>::type dereferenced;
|
||||
typedef typename add_reference<typename add_const<State>::type>::type lvalue_state;
|
||||
typedef typename boost::result_of<F(dereferenced, lvalue_state)>::type type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct static_fold;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
@ -43,14 +44,15 @@ namespace boost { namespace fusion { namespace detail
|
||||
replacer(T const& old_value, T const& new_value)
|
||||
: old_value(old_value), new_value(new_value) {}
|
||||
|
||||
template<typename Params>
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename U1, typename U2>
|
||||
struct result<replacer<U1>(U2)>
|
||||
{
|
||||
typedef typename remove_reference<U2>::type value;
|
||||
typedef typename
|
||||
mpl::if_<is_convertible<T, U2>, U2, U2 const&>::type
|
||||
mpl::if_<is_convertible<T, value>, value, value const&>::type
|
||||
type;
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
@ -49,8 +50,9 @@ namespace boost { namespace fusion { namespace detail
|
||||
template <typename F1, typename T1, typename U>
|
||||
struct result<replacer_if<F1, T1>(U)>
|
||||
{
|
||||
typedef typename remove_reference<U>::type value;
|
||||
typedef typename
|
||||
mpl::if_<is_convertible<T, U>, U, U const&>::type
|
||||
mpl::if_<is_convertible<T, value>, value, value const&>::type
|
||||
type;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user