Support removing the C++11 standard reference wrappers.

This commit is contained in:
Kohei Takahashi
2015-01-15 18:58:33 +09:00
parent 54dedc5e98
commit ce8bf1079a
5 changed files with 47 additions and 2 deletions

View File

@ -12,6 +12,10 @@
#include <boost/fusion/support/config.hpp>
#include <boost/ref.hpp>
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <functional>
#endif
namespace boost { namespace fusion { namespace traits
{
template <typename T> struct deduce;
@ -86,6 +90,21 @@ namespace boost { namespace fusion { namespace traits
typedef T& type;
};
// Also unwrap C++11 std::ref if available (referencee cv is deduced)
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
template <typename T>
struct deduce<std::reference_wrapper<T> &>
{
typedef T& type;
};
template <typename T>
struct deduce<std::reference_wrapper<T> const &>
{
typedef T& type;
};
#endif
// Keep references on arrays, even if const
template <typename T, int N>

View File

@ -11,6 +11,10 @@
#include <boost/fusion/support/config.hpp>
#include <boost/ref.hpp>
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <functional>
#endif
namespace boost { namespace fusion { namespace detail
{
template <typename T>
@ -25,6 +29,14 @@ namespace boost { namespace fusion { namespace detail
typedef T& type;
};
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
template <typename T>
struct as_fusion_element<std::reference_wrapper<T> >
{
typedef T& type;
};
#endif
template <typename T, int N>
struct as_fusion_element<T[N]>
{