Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82631 - in trunk/libs/fusion/test: functional sequence
From: joel_at_[hidden]
Date: 2013-01-27 05:14:18


Author: djowel
Date: 2013-01-27 05:14:16 EST (Sun, 27 Jan 2013)
New Revision: 82631
URL: http://svn.boost.org/trac/boost/changeset/82631

Log:
Workaround for some tests on C++11 to allow disambiguation of && and const& arguments to ctors
Text files modified:
   trunk/libs/fusion/test/functional/invoke.cpp | 14 ++++++++++++++
   trunk/libs/fusion/test/functional/invoke_function_object.cpp | 14 ++++++++++++++
   trunk/libs/fusion/test/functional/invoke_procedure.cpp | 15 +++++++++++++++
   trunk/libs/fusion/test/sequence/value_at.hpp | 17 +++++++++++++++--
   4 files changed, 58 insertions(+), 2 deletions(-)

Modified: trunk/libs/fusion/test/functional/invoke.cpp
==============================================================================
--- trunk/libs/fusion/test/functional/invoke.cpp (original)
+++ trunk/libs/fusion/test/functional/invoke.cpp 2013-01-27 05:14:16 EST (Sun, 27 Jan 2013)
@@ -10,6 +10,10 @@
 #include <boost/fusion/functional/invocation/invoke.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <functional>
+#endif
+
 #include <memory>
 #include <boost/noncopyable.hpp>
 
@@ -371,7 +375,17 @@
     vector0 v0;
     vector1 v1(element1);
     vector2 v2(element1, element2);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ // Note: C++11 will pickup the rvalue overload for the d argument
+ // since we do not have all permutations (expensive!) for all const&
+ // and && arguments. We either have all && or all const& arguments only.
+ // For that matter, use std::ref to disambiguate the call.
+
+ vector3 v3(element1, element2, std::ref(element3));
+#else
     vector3 v3(element1, element2, element3);
+#endif
 
     test_sequence(v0);
     test_sequence(v1);

Modified: trunk/libs/fusion/test/functional/invoke_function_object.cpp
==============================================================================
--- trunk/libs/fusion/test/functional/invoke_function_object.cpp (original)
+++ trunk/libs/fusion/test/functional/invoke_function_object.cpp 2013-01-27 05:14:16 EST (Sun, 27 Jan 2013)
@@ -10,6 +10,10 @@
 #include <boost/fusion/functional/invocation/invoke_function_object.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <functional>
+#endif
+
 #include <boost/type_traits/is_same.hpp>
 
 #include <memory>
@@ -209,7 +213,17 @@
     vector0 v0;
     vector1 v1(element1);
     vector2 v2(element1, element2);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ // Note: C++11 will pickup the rvalue overload for the d argument
+ // since we do not have all permutations (expensive!) for all const&
+ // and && arguments. We either have all && or all const& arguments only.
+ // For that matter, use std::ref to disambiguate the call.
+
+ vector3 v3(element1, element2, std::ref(element3));
+#else
     vector3 v3(element1, element2, element3);
+#endif
 
     test_sequence(v0);
     test_sequence(v1);

Modified: trunk/libs/fusion/test/functional/invoke_procedure.cpp
==============================================================================
--- trunk/libs/fusion/test/functional/invoke_procedure.cpp (original)
+++ trunk/libs/fusion/test/functional/invoke_procedure.cpp 2013-01-27 05:14:16 EST (Sun, 27 Jan 2013)
@@ -10,6 +10,10 @@
 #include <boost/fusion/functional/invocation/invoke_procedure.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <functional>
+#endif
+
 #include <memory>
 #include <boost/noncopyable.hpp>
 
@@ -256,8 +260,19 @@
 
     vector0 v0;
     vector1 v1(element1);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ // Note: C++11 will pickup the rvalue overload for the d argument
+ // since we do not have all permutations (expensive!) for all const&
+ // and && arguments. We either have all && or all const& arguments only.
+ // For that matter, use std::ref to disambiguate the call.
+
+ vector2 v2(std::ref(element1), element2);
+ vector3 v3(std::ref(element1), element2, std::ref(element3));
+#else
     vector2 v2(element1, element2);
     vector3 v3(element1, element2, element3);
+#endif
 
     test_sequence(v0);
     test_sequence(v1);

Modified: trunk/libs/fusion/test/sequence/value_at.hpp
==============================================================================
--- trunk/libs/fusion/test/sequence/value_at.hpp (original)
+++ trunk/libs/fusion/test/sequence/value_at.hpp 2013-01-27 05:14:16 EST (Sun, 27 Jan 2013)
@@ -2,7 +2,7 @@
     Copyright (c) 1999-2003 Jaakko Jarvi
     Copyright (c) 2001-2011 Joel de Guzman
 
- Distributed under the Boost Software License, Version 1.0. (See accompanying
+ 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)
 ==============================================================================*/
 #include <boost/detail/lightweight_test.hpp>
@@ -11,6 +11,10 @@
 #include <boost/static_assert.hpp>
 #include <iostream>
 
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <functional>
+#endif
+
 #if !defined(FUSION_AT)
 #define FUSION_AT at_c
 #endif
@@ -35,7 +39,16 @@
 
     double d = 2.7;
     A a;
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ // Note: C++11 will pickup the rvalue overload for the d argument
+ // since we do not have all permutations (expensive!) for all const&
+ // and && arguments. We either have all && or all const& arguments only.
+ // For that matter, use std::ref to disambiguate the call.
+
+ FUSION_SEQUENCE<int, double&, const A&, int> t(1, std::ref(d), a, 2);
+#else
     FUSION_SEQUENCE<int, double&, const A&, int> t(1, d, a, 2);
+#endif
     const FUSION_SEQUENCE<int, double&, const A, int> ct(t);
 
     int i = FUSION_AT<0>(t);
@@ -66,7 +79,7 @@
 
     ++FUSION_AT<0>(t);
     BOOST_TEST(FUSION_AT<0>(t) == 6);
-
+
     typedef FUSION_SEQUENCE<int, float> seq_type;
 
     BOOST_STATIC_ASSERT(!(


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk