Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54948 - in trunk: boost/mpl/aux_ libs/mpl/test
From: steven_at_[hidden]
Date: 2009-07-14 12:49:46


Author: steven_watanabe
Date: 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
New Revision: 54948
URL: http://svn.boost.org/trac/boost/changeset/54948

Log:
Fix default implementation of has_push_back and has_push_front
Added:
   trunk/libs/mpl/test/push_back.cpp (contents, props changed)
Text files modified:
   trunk/boost/mpl/aux_/push_back_impl.hpp | 11 +++++------
   trunk/boost/mpl/aux_/push_front_impl.hpp | 11 +++++------
   trunk/libs/mpl/test/Jamfile.v2 | 1 +
   trunk/libs/mpl/test/push_front.cpp | 10 ++++++++++
   4 files changed, 21 insertions(+), 12 deletions(-)

Modified: trunk/boost/mpl/aux_/push_back_impl.hpp
==============================================================================
--- trunk/boost/mpl/aux_/push_back_impl.hpp (original)
+++ trunk/boost/mpl/aux_/push_back_impl.hpp 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
@@ -25,8 +25,7 @@
 
 namespace boost { namespace mpl {
 
-template< typename Tag >
-struct has_push_back_impl;
+struct has_push_back_arg;
 
 // agurt 05/feb/04: no default implementation; the stub definition is needed
 // to enable the default 'has_push_back' implementation below
@@ -39,7 +38,7 @@
         // if you've got an assert here, you are requesting a 'push_back'
         // specialization that doesn't exist.
         BOOST_MPL_ASSERT_MSG(
- ( boost::is_same< T, has_push_back_impl<T> >::value )
+ ( boost::is_same< T, has_push_back_arg >::value )
             , REQUESTED_PUSH_BACK_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
             , ( Sequence )
             );
@@ -51,13 +50,13 @@
 {
     template< typename Seq > struct apply
 #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
- : aux::has_type< push_back< Seq, has_push_back_impl<Tag> > >
+ : aux::has_type< push_back< Seq, has_push_back_arg > >
     {
 #else
     {
- typedef aux::has_type< push_back< Seq, has_push_back_impl<Tag> > > type;
+ typedef aux::has_type< push_back< Seq, has_push_back_arg > > type;
         BOOST_STATIC_CONSTANT(bool, value =
- (aux::has_type< push_back< Seq, has_push_back_impl<Tag> > >::value)
+ (aux::has_type< push_back< Seq, has_push_back_arg > >::value)
             );
 #endif
     };

Modified: trunk/boost/mpl/aux_/push_front_impl.hpp
==============================================================================
--- trunk/boost/mpl/aux_/push_front_impl.hpp (original)
+++ trunk/boost/mpl/aux_/push_front_impl.hpp 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
@@ -25,8 +25,7 @@
 
 namespace boost { namespace mpl {
 
-template< typename Tag >
-struct has_push_front_impl;
+struct has_push_front_arg;
 
 // agurt 05/feb/04: no default implementation; the stub definition is needed
 // to enable the default 'has_push_front' implementation below
@@ -40,7 +39,7 @@
         // if you've got an assert here, you are requesting a 'push_front'
         // specialization that doesn't exist.
         BOOST_MPL_ASSERT_MSG(
- ( boost::is_same< T, has_push_front_impl<T> >::value )
+ ( boost::is_same< T, has_push_front_arg >::value )
             , REQUESTED_PUSH_FRONT_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
             , ( Sequence )
             );
@@ -52,13 +51,13 @@
 {
     template< typename Seq > struct apply
 #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
- : aux::has_type< push_front< Seq, has_push_front_impl<Tag> > >
+ : aux::has_type< push_front< Seq, has_push_front_arg > >
     {
 #else
     {
- typedef aux::has_type< push_front< Seq, has_push_front_impl<Tag> > > type;
+ typedef aux::has_type< push_front< Seq, has_push_front_arg > > type;
         BOOST_STATIC_CONSTANT(bool, value =
- (aux::has_type< push_front< Seq, has_push_front_impl<Tag> > >::value)
+ (aux::has_type< push_front< Seq, has_push_front_arg > >::value)
             );
 #endif
     };

Modified: trunk/libs/mpl/test/Jamfile.v2
==============================================================================
--- trunk/libs/mpl/test/Jamfile.v2 (original)
+++ trunk/libs/mpl/test/Jamfile.v2 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
@@ -66,6 +66,7 @@
 compile pair_view.cpp ;
 compile partition.cpp ;
 compile pop_front.cpp ;
+compile push_back.cpp ;
 compile push_front.cpp ;
 compile quote.cpp ;
 compile range_c.cpp ;

Added: trunk/libs/mpl/test/push_back.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/mpl/test/push_back.cpp 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
@@ -0,0 +1,52 @@
+
+// Copyright Steven Watanabe 2009
+//
+// 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)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+
+// $Id$
+// $Date: 2008-10-10 02:21:07 -0700 (Fri, 10 Oct 2008) $
+// $Revision: 49240 $
+
+#include <boost/mpl/push_back.hpp>
+
+#include <boost/mpl/aux_/test.hpp>
+
+struct no_push_back_tag {};
+
+struct no_push_back
+{
+ typedef no_push_back_tag tag;
+};
+
+struct has_push_back_tag {};
+
+struct with_push_back
+{
+ typedef has_push_back_tag tag;
+};
+
+namespace boost { namespace mpl {
+
+template<>
+struct push_back_impl< has_push_back_tag >
+{
+ template<class Seq, class T> struct apply
+ {
+ typedef no_push_back type;
+ };
+};
+
+}}
+
+MPL_TEST_CASE()
+{
+ MPL_ASSERT_NOT(( has_push_back< no_push_back > ));
+ MPL_ASSERT(( has_push_back< with_push_back > ));
+
+ typedef push_back< with_push_back , int >::type test;
+ MPL_ASSERT(( is_same< test, no_push_back > ));
+}

Modified: trunk/libs/mpl/test/push_front.cpp
==============================================================================
--- trunk/libs/mpl/test/push_front.cpp (original)
+++ trunk/libs/mpl/test/push_front.cpp 2009-07-14 12:49:45 EDT (Tue, 14 Jul 2009)
@@ -1,5 +1,6 @@
 
 // Copyright Aleksey Gurtovoy 2000-2004
+// Copyright Steven Watanabe 2009
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -19,6 +20,13 @@
 
 #include <boost/mpl/aux_/test.hpp>
 
+struct no_push_front_tag {};
+
+struct no_push_front
+{
+ typedef no_push_front_tag tag;
+};
+
 MPL_TEST_CASE()
 {
     typedef push_front<list0<>,long>::type res1;
@@ -37,4 +45,6 @@
     MPL_ASSERT(( has_push_front< list1<long> > ));
 
     MPL_ASSERT_NOT(( has_push_back< list0<> > ));
+
+ MPL_ASSERT_NOT(( has_push_front< no_push_front > ));
 }


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