forked from boostorg/mpl
Fix default implementation of has_push_back and has_push_front
[SVN r54948]
This commit is contained in:
@@ -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 @@ struct push_back_impl
|
||||
// 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 @@ struct has_push_back_impl
|
||||
{
|
||||
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
|
||||
};
|
||||
|
@@ -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 @@ struct push_front_impl
|
||||
// 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 @@ struct has_push_front_impl
|
||||
{
|
||||
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
|
||||
};
|
||||
|
@@ -66,6 +66,7 @@ compile numeric_ops.cpp ;
|
||||
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 ;
|
||||
|
52
test/push_back.cpp
Normal file
52
test/push_back.cpp
Normal file
@@ -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 > ));
|
||||
}
|
@@ -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_TEST_CASE()
|
||||
MPL_ASSERT(( has_push_front< list1<long> > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_push_back< list0<> > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_push_front< no_push_front > ));
|
||||
}
|
||||
|
Reference in New Issue
Block a user