diff --git a/doc/notes.qbk b/doc/notes.qbk index 26a938fb..0377023c 100644 --- a/doc/notes.qbk +++ b/doc/notes.qbk @@ -121,7 +121,7 @@ creates a __list__ of type __list__ -[heading boost::ref] +[heading Reference Wrappers] Fusion's generation functions (e.g. __make_list__) by default stores the element types as plain non-reference types. Example: @@ -151,6 +151,8 @@ For example: See __boost_ref__ for details. +Since C++11, the standard reference wrappers (`std::ref` and `std::cref`) work as well. + [heading adt_attribute_proxy] To adapt arbitrary data types that do not allow direct access to their members, diff --git a/doc/support.qbk b/doc/support.qbk index 8c2ef1de..1a473819 100644 --- a/doc/support.qbk +++ b/doc/support.qbk @@ -254,7 +254,8 @@ Metafunction to apply __element_conversion__ to the full argument type. It removes references to `const`, references to array types are kept, even if the array is `const`. Reference wrappers are removed (see -__note_boost_ref__). +__note_boost_ref__)[footnote Since C++11, the standard reference wrappers +are also removed.]. [heading Header] diff --git a/include/boost/fusion/algorithm/auxiliary.hpp b/include/boost/fusion/algorithm/auxiliary.hpp index ec327a0b..004ae8db 100644 --- a/include/boost/fusion/algorithm/auxiliary.hpp +++ b/include/boost/fusion/algorithm/auxiliary.hpp @@ -9,5 +9,6 @@ #include #include +#include #endif diff --git a/include/boost/fusion/support/deduce.hpp b/include/boost/fusion/support/deduce.hpp index 8d53115f..b75381c5 100644 --- a/include/boost/fusion/support/deduce.hpp +++ b/include/boost/fusion/support/deduce.hpp @@ -12,6 +12,10 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif + namespace boost { namespace fusion { namespace traits { template 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 + struct deduce &> + { + typedef T& type; + }; + + template + struct deduce const &> + { + typedef T& type; + }; +#endif + // Keep references on arrays, even if const template diff --git a/include/boost/fusion/support/detail/as_fusion_element.hpp b/include/boost/fusion/support/detail/as_fusion_element.hpp index 628dca4d..2af960ee 100644 --- a/include/boost/fusion/support/detail/as_fusion_element.hpp +++ b/include/boost/fusion/support/detail/as_fusion_element.hpp @@ -11,6 +11,10 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif + namespace boost { namespace fusion { namespace detail { template @@ -25,6 +29,14 @@ namespace boost { namespace fusion { namespace detail typedef T& type; }; +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL + template + struct as_fusion_element > + { + typedef T& type; + }; +#endif + template struct as_fusion_element { diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp index e374152f..b594f6c8 100644 --- a/test/algorithm/pop_back.cpp +++ b/test/algorithm/pop_back.cpp @@ -95,7 +95,7 @@ main() #endif { - boost::array a = { 10, 50 }; + boost::array a = {{ 10, 50 }}; BOOST_TEST(back(pop_back(a)) == 10); } diff --git a/test/functional/invoke.cpp b/test/functional/invoke.cpp index 67e65feb..fa93332c 100644 --- a/test/functional/invoke.cpp +++ b/test/functional/invoke.cpp @@ -7,6 +7,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include @@ -146,11 +147,28 @@ class members int binary_c(int i, object) const { return data + 6 + i; } }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr members_ptr; +typedef std::auto_ptr const_members_ptr; +#else +typedef std::unique_ptr members_ptr; +typedef std::unique_ptr const_members_ptr; +#endif + struct derived : members { }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr derived_ptr; +typedef std::auto_ptr const_derived_ptr; +#else +typedef std::unique_ptr derived_ptr; +typedef std::unique_ptr const_derived_ptr; +#endif + + typedef int element1_type; typedef object element2_type; typedef object_nc & element3_type; @@ -161,8 +179,8 @@ object_nc element3; members that; -std::auto_ptr spt_that(new members); -std::auto_ptr spt_that_c(new members); +members_ptr spt_that(new members); +const_members_ptr spt_that_c(new members); fusion::single_view sv_obj_ctx( that); fusion::single_view sv_ref_ctx( that); @@ -170,13 +188,13 @@ fusion::single_view sv_ptr_ctx(& that); fusion::single_view sv_obj_c_ctx( that); fusion::single_view sv_ref_c_ctx( that); fusion::single_view sv_ptr_c_ctx(& that); -fusion::single_view const &> sv_spt_ctx(spt_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_ctx(spt_that_c); +fusion::single_view sv_spt_ctx(spt_that); +fusion::single_view sv_spt_c_ctx(spt_that_c); derived derived_that; -std::auto_ptr spt_derived_that(new derived); -std::auto_ptr spt_derived_that_c(new derived); +derived_ptr spt_derived_that(new derived); +const_derived_ptr spt_derived_that_c(new derived); fusion::single_view sv_obj_d_ctx( derived_that); fusion::single_view sv_ref_d_ctx( derived_that); @@ -184,8 +202,8 @@ fusion::single_view sv_ptr_d_ctx(& derived_that); fusion::single_view sv_obj_c_d_ctx( derived_that); fusion::single_view sv_ref_c_d_ctx( derived_that); fusion::single_view sv_ptr_c_d_ctx(& derived_that); -fusion::single_view const &> sv_spt_d_ctx(spt_derived_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_d_ctx(spt_derived_that_c); +fusion::single_view sv_spt_d_ctx(spt_derived_that); +fusion::single_view sv_spt_c_d_ctx(spt_derived_that_c); template void test_sequence_n(Sequence & seq, mpl::int_<0>) diff --git a/test/functional/invoke_procedure.cpp b/test/functional/invoke_procedure.cpp index 49c35d37..2ee8354d 100644 --- a/test/functional/invoke_procedure.cpp +++ b/test/functional/invoke_procedure.cpp @@ -7,6 +7,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include @@ -65,9 +66,17 @@ class members int binary_c(int & i, object) const { return i = data + 6; } }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr members_ptr; +typedef std::auto_ptr const_members_ptr; +#else +typedef std::unique_ptr members_ptr; +typedef std::unique_ptr const_members_ptr; +#endif + members that; -std::auto_ptr spt_that(new members); -std::auto_ptr spt_that_c(new members); +members_ptr spt_that(new members); +const_members_ptr spt_that_c(new members); fusion::single_view sv_obj_ctx( that); fusion::single_view sv_ref_ctx( that); @@ -75,8 +84,8 @@ fusion::single_view sv_ptr_ctx(& that); fusion::single_view sv_obj_c_ctx( that); fusion::single_view sv_ref_c_ctx( that); fusion::single_view sv_ptr_c_ctx(& that); -fusion::single_view const &> sv_spt_ctx(spt_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_ctx(spt_that_c); +fusion::single_view sv_spt_ctx(spt_that); +fusion::single_view sv_spt_c_ctx(spt_that_c); struct fobj { diff --git a/test/sequence/adapt_struct.cpp b/test/sequence/adapt_struct.cpp index e64507cf..012e8e14 100644 --- a/test/sequence/adapt_struct.cpp +++ b/test/sequence/adapt_struct.cpp @@ -178,7 +178,7 @@ main() { fusion::vector v1(4, 2); - ns::bar v2 = {5, 3}; + ns::bar v2 = {{5}, 3}; BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); diff --git a/test/sequence/deduce_sequence.cpp b/test/sequence/deduce_sequence.cpp index ea661662..a1569f46 100644 --- a/test/sequence/deduce_sequence.cpp +++ b/test/sequence/deduce_sequence.cpp @@ -6,6 +6,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include #include @@ -13,6 +14,9 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif using boost::is_same; using boost::reference_wrapper; @@ -66,6 +70,13 @@ int main() TEST_SAME_TYPE(deduce< reference_wrapper const & >::type, int &); TEST_SAME_TYPE(deduce< reference_wrapper const & >::type, int const &); +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL + TEST_SAME_TYPE(deduce< std::reference_wrapper & >::type, int &); + TEST_SAME_TYPE(deduce< std::reference_wrapper & >::type, int const &); + TEST_SAME_TYPE(deduce< std::reference_wrapper const & >::type, int &); + TEST_SAME_TYPE(deduce< std::reference_wrapper const & >::type, int const &); +#endif + TEST_SAME_TYPE(deduce< int(&)[2] >::type, int(&)[2]); TEST_SAME_TYPE(deduce< int const (&)[2] >::type, int const (&)[2]); TEST_SAME_TYPE(deduce< int volatile (&)[2] >::type, int volatile (&)[2]); diff --git a/test/sequence/move.hpp b/test/sequence/move.hpp index febbc2bb..8636604f 100644 --- a/test/sequence/move.hpp +++ b/test/sequence/move.hpp @@ -38,12 +38,12 @@ namespace test_detail return *this; } - x(x const& rhs) + x(x const& /*rhs*/) { incr_copy(); } - x& operator=(x const& rhs) + x& operator=(x const& /*rhs*/) { incr_copy(); return *this;