sync with 3ac6e46d01
This commit is contained in:
parent
50905c3f9a
commit
e296e554a8
1 changed files with 26 additions and 26 deletions
|
@ -283,29 +283,20 @@ namespace detail {
|
|||
template <typename T>
|
||||
struct unwrapper
|
||||
{
|
||||
T const& operator() (T const& obj) const
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
T& operator() (T & obj) const
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
static T const& apply_const(T const& obj) {return obj;}
|
||||
static T& apply(T & obj) {return obj;}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct unwrapper<recursive_wrapper<T>>
|
||||
{
|
||||
auto operator() (recursive_wrapper<T> const& obj) const
|
||||
static auto apply_const(recursive_wrapper<T> const& obj)
|
||||
-> typename recursive_wrapper<T>::type const&
|
||||
{
|
||||
return obj.get();
|
||||
}
|
||||
|
||||
auto operator() (recursive_wrapper<T> & obj) const
|
||||
-> typename recursive_wrapper<T>::type &
|
||||
static auto apply(recursive_wrapper<T> & obj)
|
||||
-> typename recursive_wrapper<T>::type&
|
||||
{
|
||||
return obj.get();
|
||||
}
|
||||
|
@ -314,8 +305,13 @@ struct unwrapper<recursive_wrapper<T>>
|
|||
template <typename T>
|
||||
struct unwrapper<std::reference_wrapper<T>>
|
||||
{
|
||||
auto operator() (std::reference_wrapper<T> const& obj) const
|
||||
-> typename recursive_wrapper<T>::type const&
|
||||
static auto apply_const(std::reference_wrapper<T> const& obj)
|
||||
-> typename std::reference_wrapper<T>::type const&
|
||||
{
|
||||
return obj.get();
|
||||
}
|
||||
static auto apply(std::reference_wrapper<T> & obj)
|
||||
-> typename std::reference_wrapper<T>::type&
|
||||
{
|
||||
return obj.get();
|
||||
}
|
||||
|
@ -332,7 +328,7 @@ struct dispatcher<F, V, R, T, Types...>
|
|||
{
|
||||
if (v.get_type_index() == sizeof...(Types))
|
||||
{
|
||||
return f(unwrapper<T>()(v. template get<T>()));
|
||||
return f(unwrapper<T>::apply_const(v. template get<T>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -344,7 +340,7 @@ struct dispatcher<F, V, R, T, Types...>
|
|||
{
|
||||
if (v.get_type_index() == sizeof...(Types))
|
||||
{
|
||||
return f(unwrapper<T>()(v. template get<T>()));
|
||||
return f(unwrapper<T>::apply(v. template get<T>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -380,8 +376,8 @@ struct binary_dispatcher_rhs<F, V, R, T0, T1, Types...>
|
|||
{
|
||||
if (rhs.get_type_index() == sizeof...(Types)) // call binary functor
|
||||
{
|
||||
return f(unwrapper<T0>()(lhs. template get<T0>()),
|
||||
unwrapper<T1>()(rhs. template get<T1>()));
|
||||
return f(unwrapper<T0>::apply_const(lhs. template get<T0>()),
|
||||
unwrapper<T1>::apply_const(rhs. template get<T1>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -393,8 +389,8 @@ struct binary_dispatcher_rhs<F, V, R, T0, T1, Types...>
|
|||
{
|
||||
if (rhs.get_type_index() == sizeof...(Types)) // call binary functor
|
||||
{
|
||||
return f(unwrapper<T0>()(lhs. template get<T0>()),
|
||||
unwrapper<T1>()(rhs. template get<T1>()));
|
||||
return f(unwrapper<T0>::apply(lhs. template get<T0>()),
|
||||
unwrapper<T1>::apply(rhs. template get<T1>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -430,7 +426,8 @@ struct binary_dispatcher_lhs<F, V, R, T0, T1, Types...>
|
|||
{
|
||||
if (lhs.get_type_index() == sizeof...(Types)) // call binary functor
|
||||
{
|
||||
return f(lhs. template get<T1>(), rhs. template get<T0>());
|
||||
return f(unwrapper<T1>::apply_const(lhs. template get<T1>()),
|
||||
unwrapper<T0>::apply_const(rhs. template get<T0>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -442,7 +439,8 @@ struct binary_dispatcher_lhs<F, V, R, T0, T1, Types...>
|
|||
{
|
||||
if (lhs.get_type_index() == sizeof...(Types)) // call binary functor
|
||||
{
|
||||
return f(lhs. template get<T1>(), rhs. template get<T0>());
|
||||
return f(unwrapper<T1>::apply(lhs. template get<T1>()),
|
||||
unwrapper<T0>::apply(rhs. template get<T0>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -480,7 +478,8 @@ struct binary_dispatcher<F, V, R, T, Types...>
|
|||
{
|
||||
if (v0.get_type_index() == v1.get_type_index())
|
||||
{
|
||||
return f(v0. template get<T>(), v1. template get<T>()); // call binary functor
|
||||
return f(unwrapper<T>::apply_const(v0. template get<T>()),
|
||||
unwrapper<T>::apply_const(v1. template get<T>())); // call binary functor
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -500,7 +499,8 @@ struct binary_dispatcher<F, V, R, T, Types...>
|
|||
{
|
||||
if (v0.get_type_index() == v1.get_type_index())
|
||||
{
|
||||
return f(v0. template get<T>(), v1. template get<T>()); // call binary functor
|
||||
return f(unwrapper<T>::apply(v0. template get<T>()),
|
||||
unwrapper<T>::apply(v1. template get<T>())); // call binary functor
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue