Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72133 - in sandbox/coerce: boost/coerce boost/coerce/detail libs/coerce/test
From: vexocide_at_[hidden]
Date: 2011-05-24 13:31:53


Author: vexocide
Date: 2011-05-24 13:31:51 EDT (Tue, 24 May 2011)
New Revision: 72133
URL: http://svn.boost.org/trac/boost/changeset/72133

Log:
Fixed the push_back SFINAE check
Text files modified:
   sandbox/coerce/boost/coerce/coerce.hpp | 2 +-
   sandbox/coerce/boost/coerce/detail/push_back.hpp | 25 +++++++++++++++++++++----
   sandbox/coerce/libs/coerce/test/integral.cpp | 2 +-
   3 files changed, 23 insertions(+), 6 deletions(-)

Modified: sandbox/coerce/boost/coerce/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/coerce.hpp (original)
+++ sandbox/coerce/boost/coerce/coerce.hpp 2011-05-24 13:31:51 EDT (Tue, 24 May 2011)
@@ -26,7 +26,7 @@
         template <typename Target, typename Source, typename Enable = void>
         struct as
             : detail::backend<
- typename detail::has_push_back<Target>::type,
+ typename detail::is_back_insertion_sequence<Target>::type,
                 typename has_range_const_iterator<Source>::type
>::type { };
 

Modified: sandbox/coerce/boost/coerce/detail/push_back.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/detail/push_back.hpp (original)
+++ sandbox/coerce/boost/coerce/detail/push_back.hpp 2011-05-24 13:31:51 EDT (Tue, 24 May 2011)
@@ -12,28 +12,45 @@
 #endif
 
 #include <boost/config.hpp>
+#include <boost/mpl/and.hpp>
 #include <boost/mpl/bool.hpp>
+#include <boost/mpl/has_xxx.hpp>
 #include <boost/type_traits/detail/yes_no_type.hpp>
 
 namespace boost { namespace coerce { namespace detail {
 
- template <typename Sequence>
+ template <typename T>
     class has_push_back {
+ template <typename U, void (U::*)(typename U::const_reference) = &U::push_back>
+ struct const_reference { };
+
+ template <typename U>
+ static type_traits::yes_type test(U*, const_reference<U>* = 0);
+
         template <typename U, void (U::*)(typename U::value_type) = &U::push_back>
- struct impl { };
+ struct value_type { };
 
         template <typename U>
- static type_traits::yes_type test(U*, impl<U>* = 0);
+ static type_traits::yes_type test(U*, value_type<U>* = 0);
 
         template <typename U>
         static type_traits::no_type test(...);
 
     public:
         BOOST_STATIC_CONSTANT(bool, value =
- sizeof(test<Sequence>(0)) == sizeof(type_traits::yes_type));
+ sizeof(test<T>(0)) == sizeof(type_traits::yes_type));
         typedef mpl::bool_<value> type;
     };
 
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(const_reference)
+
+ template <typename T>
+ struct is_back_insertion_sequence
+ : mpl::and_<
+ has_push_back<T>,
+ has_const_reference<T>
+ > { };
+
 } } } // namespace boost::coerce::detail
 
 #endif // BOOST_COERCE_DETAIL_PUSH_BACK_HPP

Modified: sandbox/coerce/libs/coerce/test/integral.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/test/integral.cpp (original)
+++ sandbox/coerce/libs/coerce/test/integral.cpp 2011-05-24 13:31:51 EDT (Tue, 24 May 2011)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2010.
+// Copyright Jeroen Habraken 2011.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file ../../../LICENSE_1_0.txt or copy at


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