[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

97
libs/mpl/test/Jamfile.v2 Normal file
View File

@@ -0,0 +1,97 @@
compile aux_/increased_arity.cpp ;
compile aux_/largest_int.cpp ;
compile aux_/msvc_is_class.cpp ;
compile aux_/template_arity.cpp ;
compile aux_/preprocessor/is_seq.cpp ;
compile aux_/preprocessor/token_equal.cpp ;
compile advance.cpp ;
compile always.cpp ;
compile apply.cpp ;
compile apply_wrap.cpp ;
compile arithmetic.cpp ;
compile as_sequence.cpp ;
compile assert.cpp ;
compile at.cpp ;
compile back.cpp ;
compile bind.cpp ;
compile bitwise.cpp ;
run bool.cpp ;
compile comparison.cpp ;
compile contains.cpp ;
compile copy.cpp ;
compile copy_if.cpp ;
compile count.cpp ;
compile count_if.cpp ;
compile deque.cpp ;
compile distance.cpp ;
compile empty.cpp ;
compile equal.cpp ;
compile erase.cpp ;
compile erase_range.cpp ;
compile eval_if.cpp ;
compile filter_view.cpp ;
compile find.cpp ;
compile find_if.cpp ;
compile fold.cpp ;
run for_each.cpp ;
compile front.cpp ;
compile get_tag_def.cpp ;
compile has_xxx.cpp ;
compile identity.cpp ;
compile if.cpp ;
compile index_of.cpp ;
compile inherit.cpp ;
compile insert.cpp ;
compile insert_range.cpp ;
run int.cpp ;
run char.cpp ;
run integral_c.cpp : : : <toolset>vacpp:<cxxflags>-qchars=signed ;
compile is_placeholder.cpp ;
compile is_sequence.cpp ;
compile iterator_tags.cpp ;
compile joint_view.cpp ;
compile lambda.cpp ;
compile lambda_args.cpp ;
compile list.cpp ;
compile list_c.cpp ;
compile logical.cpp ;
compile lower_bound.cpp ;
compile map.cpp ;
compile max_element.cpp ;
compile min_max.cpp ;
compile multiset.cpp ;
compile next.cpp ;
compile no_has_xxx.cpp ;
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 ;
compile remove.cpp ;
compile remove_if.cpp ;
compile replace.cpp ;
compile replace_if.cpp ;
compile reverse.cpp ;
compile same_as.cpp ;
compile set.cpp ;
compile set_c.cpp ;
compile single_view.cpp ;
compile size.cpp ;
run size_t.cpp ;
compile sizeof.cpp ;
compile sort.cpp ;
compile stable_partition.cpp ;
compile transform.cpp ;
compile transform_view.cpp ;
compile unique.cpp ;
compile unpack_args.cpp ;
compile upper_bound.cpp ;
compile vector.cpp ;
compile vector_c.cpp ;
compile zip_view.cpp ;
run string.cpp ;

51
libs/mpl/test/advance.cpp Normal file
View File

@@ -0,0 +1,51 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/advance.hpp>
#include <boost/mpl/iterator_tags.hpp>
#include <boost/mpl/aux_/test.hpp>
template< int pos > struct iter
{
typedef mpl::bidirectional_iterator_tag category;
typedef iter<(pos + 1)> next;
typedef iter<(pos - 1)> prior;
typedef int_<pos> type;
};
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
namespace boost { namespace mpl {
template< int pos, typename Default > struct tag< iter<pos>,Default > : void_ {};
}}
#endif
typedef iter<0> first;
typedef iter<10> last;
MPL_TEST_CASE()
{
typedef mpl::advance<first,int_<10> >::type iter1;
typedef advance_c<first,10>::type iter2;
MPL_ASSERT(( is_same<iter1, last> ));
MPL_ASSERT(( is_same<iter2, last> ));
}
MPL_TEST_CASE()
{
typedef mpl::advance<last,int_<-10> >::type iter1;
typedef advance_c<last,-10>::type iter2;
MPL_ASSERT(( is_same<iter1, first> ));
MPL_ASSERT(( is_same<iter2, first> ));
}

48
libs/mpl/test/always.cpp Normal file
View File

@@ -0,0 +1,48 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/apply.hpp>
#include <boost/mpl/always.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef always<true_> always_true;
MPL_ASSERT(( apply< always_true > ));
MPL_ASSERT(( apply0< always_true > ));
MPL_ASSERT(( apply1< always_true,false_ > ));
MPL_ASSERT(( apply2< always_true,false_,false_ > ));
MPL_ASSERT(( apply3< always_true,false_,false_,false_ > ));
}
MPL_TEST_CASE()
{
typedef always< int_<10> > always_10;
typedef apply< always_10 >::type res;
typedef apply0< always_10 >::type res0;
typedef apply1< always_10,int_<0> >::type res1;
typedef apply2< always_10,int_<0>,int_<0> >::type res2;
typedef apply3< always_10,int_<0>,int_<0>,int_<0> >::type res3;
MPL_ASSERT_RELATION( res::value, ==, 10 );
MPL_ASSERT_RELATION( res0::value, ==, 10 );
MPL_ASSERT_RELATION( res1::value, ==, 10 );
MPL_ASSERT_RELATION( res2::value, ==, 10 );
MPL_ASSERT_RELATION( res3::value, ==, 10 );
}

128
libs/mpl/test/apply.cpp Normal file
View File

@@ -0,0 +1,128 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/apply.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct std_vector
{
#if defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS)
typedef std_vector type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(1, std_vector, (T))
#endif
};
MPL_TEST_CASE()
{
typedef plus<int_<2>,int_<3> > plus1;
typedef lambda<plus1>::type plus2;
MPL_ASSERT(( is_same< plus1,plus2 > ));
typedef lambda<std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef lambda<std_vector<_1> >::type make_vector;
typedef apply_wrap1<make_vector,int>::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef plus<_1,_2> plus_fun;
typedef apply2<plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef apply1<_1, plus<_1,_2> >::type plus_fun;
MPL_ASSERT(( is_same< plus_fun,plus<_1,_2> > ));
typedef apply2<plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef lambda< lambda<_1> >::type make_lambda;
typedef apply_wrap1< make_lambda,std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply_wrap1< make_lambda,std_vector<_1> >::type make_vector;
typedef apply_wrap1< make_vector,int >::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< _1, std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply1< _1, std_vector<_1> >::type v_lambda;
typedef apply1<v_lambda,int>::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< lambda<_1>, std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply1< lambda<_1>, std_vector<_1> >::type make_vector;
typedef apply_wrap1< make_vector,int >::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< lambda<_1>, plus<_1,_2> >::type plus_fun;
typedef apply_wrap2< plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef bind2<plus<>,_1,_1> b1;
typedef lambda<b1>::type b2;
MPL_ASSERT(( is_same< b1,b2 > ));
}
MPL_TEST_CASE()
{
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
typedef lambda< lambda< bind2<plus<>,_1,_1> > >::type make_lambda;
typedef apply_wrap1< make_lambda::type, int_<5> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 10 );
#endif
}
MPL_TEST_CASE()
{
typedef apply1< bind2<plus<>,_1,_1>, int_<5> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 10 );
}
MPL_TEST_CASE()
{
typedef apply1<_1, lambda<plus<_1,_2> > >::type plus_fun;
typedef apply_wrap2< plus_fun::type, int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}

View File

@@ -0,0 +1,121 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/limits/arity.hpp>
#include <boost/mpl/aux_/preprocessor/params.hpp>
#include <boost/mpl/aux_/preprocessor/enum.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/if.hpp>
#include <boost/preprocessor/cat.hpp>
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T = int > struct apply { typedef char type; }; \
}; \
/**/
#else
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T > struct apply { typedef char type; }; \
}; \
/**/
#endif
#define APPLY_N_FUNC_DEF(i) \
struct first##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef U1 type; }; \
}; \
\
struct last##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef BOOST_PP_CAT(U,i) type; }; \
}; \
/**/
#define APPLY_FUNC_DEF(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_FUNC_DEF \
, APPLY_0_FUNC_DEF \
)(i) \
/**/
namespace { namespace test {
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_FUNC_DEF
, unused
)
struct g0 { struct apply { typedef char type; }; };
}}
#define APPLY_0_TEST(i, apply_) \
typedef apply_<test::f##i>::type t; \
{ MPL_ASSERT(( boost::is_same<t, char> )); } \
/**/
#define APPLY_N_TEST(i, apply_) \
typedef apply_< \
test::first##i \
, char \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
>::type t1##i; \
\
typedef apply_< \
test::last##i \
, BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
>::type t2##i; \
{ MPL_ASSERT(( boost::is_same<t1##i, char> )); } \
{ MPL_ASSERT(( boost::is_same<t2##i, char> )); } \
/**/
#define APPLY_TEST(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_TEST \
, APPLY_0_TEST \
)(i, BOOST_PP_CAT(apply_wrap,i)) \
/**/
MPL_TEST_CASE()
{
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_TEST
, unused
)
#if !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
{
typedef apply_wrap0<test::g0>::type t;
MPL_ASSERT(( boost::is_same<t, char> ));
}
#endif
}

View File

@@ -0,0 +1,50 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef int_<0> _0;
typedef int_<1> _1;
typedef int_<3> _3;
typedef int_<10> _10;
MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 );
MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 );
MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 );
MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 );
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 );
MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 );
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
#endif
MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 );
}

View File

@@ -0,0 +1,23 @@
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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$
// $Revision$
#include <boost/mpl/as_sequence.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( is_sequence< as_sequence<int>::type > ));
MPL_ASSERT(( is_sequence< as_sequence<UDT>::type > ));
MPL_ASSERT(( is_sequence< as_sequence< vector<> >::type > ));
}

101
libs/mpl/test/assert.cpp Normal file
View File

@@ -0,0 +1,101 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_pointer.hpp>
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () );
namespace my {
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () );
}
template< typename T >
struct her
{
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () );
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) );
#endif
void f()
{
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
#endif
BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () );
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) );
#endif
}
};
template<class T>
struct nested : boost::mpl::true_ {
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
};
BOOST_MPL_ASSERT(( nested<int> ));
BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > ));
int main()
{
her<void> h;
h.f();
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () );
return 0;
}

39
libs/mpl/test/at.cpp Normal file
View File

@@ -0,0 +1,39 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/at.hpp>
#include <boost/mpl/vector/vector10_c.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename Seq, int n > struct at_test
{
typedef typename at_c<Seq,n>::type t;
MPL_ASSERT(( is_same< t, integral_c<int,9-n> > ));
MPL_ASSERT_RELATION( t::value, ==, 9 - n );
};
MPL_TEST_CASE()
{
typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
at_test< numbers, 0 >();
at_test< numbers, 1 >();
at_test< numbers, 2 >();
at_test< numbers, 3 >();
at_test< numbers, 4 >();
at_test< numbers, 5 >();
at_test< numbers, 6 >();
at_test< numbers, 7 >();
at_test< numbers, 8 >();
at_test< numbers, 9 >();
}

View File

@@ -0,0 +1,50 @@
// Copyright Bruno Dutra 2015
//
// 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$
// $Revision$
#define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 15
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#include <boost/mpl/logical.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/repeat_from_to.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#define TEST_N_ARY(unused1, N, unused2) \
static_assert_< \
apply< \
and_<BOOST_PP_ENUM_PARAMS(N, _ BOOST_PP_INTERCEPT)>, \
BOOST_PP_ENUM_PARAMS(N, true_ BOOST_PP_INTERCEPT) \
> \
>(); \
/**/
template<typename assertion>
void static_assert_(){
MPL_ASSERT((typename assertion::type));
}
MPL_TEST_CASE()
{
BOOST_PP_REPEAT_FROM_TO(
2,
BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY),
TEST_N_ARY,
_
)
}

View File

@@ -0,0 +1,25 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/aux_/largest_int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,bool>::type, bool > ));
MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,char>::type, char > ));
MPL_ASSERT(( is_same< mpl::aux::largest_int<char,bool>::type, char > ));
MPL_ASSERT(( is_same< mpl::aux::largest_int<int,unsigned>::type, unsigned > ));
MPL_ASSERT(( is_same< mpl::aux::largest_int<unsigned,long>::type, long > ));
}

View File

@@ -0,0 +1,46 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/aux_/config/msvc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
#include <boost/mpl/aux_/msvc_is_class.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct A { T x[0]; };
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( aux::msvc_is_class< int > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< char > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< enum_ > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< char* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< UDT* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< UDT& > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete& > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< int[5] > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< void (*)() > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< int (*)(int, char) > ));
MPL_ASSERT(( aux::msvc_is_class< UDT > ));
MPL_ASSERT(( aux::msvc_is_class< incomplete > ));
MPL_ASSERT(( aux::msvc_is_class< abstract > ));
MPL_ASSERT(( aux::msvc_is_class< noncopyable > ));
MPL_ASSERT(( aux::msvc_is_class< A<int> > ));
MPL_ASSERT(( aux::msvc_is_class< A<incomplete> > ));
}
#endif

View File

@@ -0,0 +1,33 @@
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/aux_/preprocessor/is_seq.hpp>
#include <boost/preprocessor/logical/not.hpp>
#include <boost/preprocessor/debug/assert.hpp>
#define AUX_ASSERT_IS_SEQ( seq ) \
BOOST_PP_ASSERT( BOOST_MPL_PP_IS_SEQ(seq) ) \
/**/
#define AUX_ASSERT_IS_NOT_SEQ( seq ) \
BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_IS_SEQ(seq) ) ) \
/**/
#define SEQ (a)(b)(c)
AUX_ASSERT_IS_NOT_SEQ( a )
AUX_ASSERT_IS_SEQ( (a) )
AUX_ASSERT_IS_SEQ( (a)(b) )
AUX_ASSERT_IS_SEQ( (a)(b)(c) )
AUX_ASSERT_IS_SEQ( SEQ )

View File

@@ -0,0 +1,36 @@
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
#include <boost/preprocessor/logical/not.hpp>
#include <boost/preprocessor/debug/assert.hpp>
#define AUX_ASSERT_EQUAL(x, y) \
BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) \
/**/
#define AUX_ASSERT_NOT_EQUAL(x, y) \
BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) ) \
/**/
#define BOOST_MPL_PP_TOKEN_EQUAL_apple(x) x
#define BOOST_MPL_PP_TOKEN_EQUAL_orange(x) x
AUX_ASSERT_NOT_EQUAL( apple, abc )
AUX_ASSERT_NOT_EQUAL( abc, apple )
AUX_ASSERT_NOT_EQUAL( apple, orange )
AUX_ASSERT_NOT_EQUAL( orange, apple )
AUX_ASSERT_EQUAL( apple, apple )
AUX_ASSERT_EQUAL( orange, orange )

View File

@@ -0,0 +1,31 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/aux_/template_arity.hpp>
#include <boost/mpl/aux_/test.hpp>
#if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
struct my {};
template< typename T1 > struct my1 {};
template< typename T1, typename T2 = void > struct my2 {};
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (aux::template_arity<my>::value), ==, -1 );
MPL_ASSERT_RELATION( (aux::template_arity< my1<int> >::value), ==, 1 );
MPL_ASSERT_RELATION( (aux::template_arity< my2<int,long> >::value), ==, 2 );
MPL_ASSERT_RELATION( (aux::template_arity< my2<int> >::value), ==, 2 );
}
#endif

29
libs/mpl/test/back.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/back.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename Seq, int value > struct back_test
{
typedef typename back<Seq>::type t;
MPL_ASSERT_RELATION( t::value, ==, value );
};
MPL_TEST_CASE()
{
back_test< range_c<int,0,1>, 0 >();
back_test< range_c<int,0,10>, 9 >();
back_test< range_c<int,-10,0>, -1 >();
}

89
libs/mpl/test/bind.cpp Normal file
View File

@@ -0,0 +1,89 @@
// Copyright Peter Dimov 2001-2002
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/bind.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
namespace {
struct f1
{
template< typename T1 > struct apply
{
typedef T1 type;
};
};
struct f5
{
template< typename T1, typename T2, typename T3, typename T4, typename T5 >
struct apply
{
typedef T5 type;
};
};
} // namespace
MPL_TEST_CASE() // basic argument binding
{
typedef apply_wrap1< bind1<f1,_1>, int >::type r11;
typedef apply_wrap5< bind1<f1,_5>, void,void,void,void,int >::type r12;
MPL_ASSERT(( boost::is_same<r11,int> ));
MPL_ASSERT(( boost::is_same<r12,int> ));
typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,_5>, void,void,void,void,int >::type r51;
typedef apply_wrap5< bind5<f5,_5,_4,_3,_2,_1>, int,void,void,void,void >::type r52;
MPL_ASSERT(( boost::is_same<r51,int> ));
MPL_ASSERT(( boost::is_same<r52,int> ));
}
MPL_TEST_CASE() // fully bound metafunction classes
{
typedef apply_wrap0< bind1<f1,int> >::type r11;
typedef apply_wrap0< bind5<f5,void,void,void,void,int> >::type r51;
MPL_ASSERT(( boost::is_same<r11,int> ));
MPL_ASSERT(( boost::is_same<r51,int> ));
}
MPL_TEST_CASE() // metafunction class composition
{
typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_1> >, int,void,void,void,void >::type r51;
typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_5> >, void,void,void,void,int >::type r52;
MPL_ASSERT(( boost::is_same<r51,int> ));
MPL_ASSERT(( boost::is_same<r52,int> ));
}
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) \
&& !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
MPL_TEST_CASE() // if_ evaluation
{
typedef bind3< quote3<if_>, _1, bind1< quote1<next>, _2>, _3 > f;
typedef apply_wrap3< f,true_,int_<0>,int >::type r1;
typedef apply_wrap3< f,false_,int,int_<0> >::type r2;
MPL_ASSERT(( boost::is_same<r1,int_<1> > ));
MPL_ASSERT(( boost::is_same<r2,int_<0> > ));
}
#endif

71
libs/mpl/test/bitwise.cpp Normal file
View File

@@ -0,0 +1,71 @@
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright Jaap Suter 2003
//
// 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$
// $Revision$
#include <boost/mpl/bitwise.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/aux_/test.hpp>
typedef integral_c<unsigned int, 0> _0;
typedef integral_c<unsigned int, 1> _1;
typedef integral_c<unsigned int, 2> _2;
typedef integral_c<unsigned int, 8> _8;
typedef integral_c<unsigned int, 0xffffffff> _ffffffff;
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (bitand_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_1,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_0,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_0,_ffffffff>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_1,_ffffffff>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitand_<_8,_ffffffff>::value), ==, 8 );
}
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (bitor_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitor_<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitor_<_0,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
}
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (bitxor_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitxor_<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitxor_<_0,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 0) );
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 1) );
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 8) );
}
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (shift_right<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_right<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_right<_1,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_right<_2,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_right<_8,_1>::value), ==, 4 );
}
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (shift_left<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_left<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_left<_1,_1>::value), ==, 2 );
MPL_ASSERT_RELATION( (shift_left<_2,_1>::value), ==, 4 );
MPL_ASSERT_RELATION( (shift_left<_8,_1>::value), ==, 16 );
}

38
libs/mpl/test/bool.cpp Normal file
View File

@@ -0,0 +1,38 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <cassert>
#if defined(BOOST_NO_CXX11_CONSTEXPR)
#define CONSTEXPR_BOOL_TEST(c)
#else
#define CONSTEXPR_BOOL_TEST(c) { static_assert(bool_<c>() == c, "Constexpr for bool_ failed"); }
#endif
#define BOOL_TEST(c) \
{ MPL_ASSERT(( is_same< bool_<c>::value_type, bool > )); } \
{ MPL_ASSERT(( is_same< bool_<c>, c##_ > )); } \
{ MPL_ASSERT(( is_same< bool_<c>::type, bool_<c> > )); } \
{ MPL_ASSERT_RELATION( bool_<c>::value, ==, c ); } \
CONSTEXPR_BOOL_TEST(c) \
BOOST_TEST( bool_<c>() == c ); \
/**/
MPL_TEST_CASE()
{
BOOL_TEST(true)
BOOL_TEST(false)
}

24
libs/mpl/test/char.cpp Normal file
View File

@@ -0,0 +1,24 @@
// Copyright Eric Niebler 2008
//
// 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: char.cpp 49240 2009-04-01 09:21:07Z eric_niebler $
// $Date: 2009-04-01 02:21:07 -0700 (Wed, 1 Apr 2009) $
// $Revision: 49240 $
#include <boost/mpl/char.hpp>
#include <boost/preprocessor/repeat.hpp>
#include "integral_wrapper_test.hpp"
MPL_TEST_CASE()
{
# define WRAPPER(T, i) char_<i>
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char)
}

View File

@@ -0,0 +1,64 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
// make sure MSVC behaves nicely in presence of the following template
template< typename T > struct value {};
typedef int_<0> _0;
typedef int_<10> _10;
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( equal_to<_0, _10> ));
MPL_ASSERT_NOT(( equal_to<_10, _0> ));
MPL_ASSERT(( equal_to<_10, _10> ));
}
MPL_TEST_CASE()
{
MPL_ASSERT(( not_equal_to<_0, _10> ));
MPL_ASSERT(( not_equal_to<_10, _0> ));
MPL_ASSERT_NOT(( not_equal_to<_10, _10> ));
}
MPL_TEST_CASE()
{
MPL_ASSERT(( less<_0, _10> ));
MPL_ASSERT_NOT(( less<_10, _0> ));
MPL_ASSERT_NOT(( less<_10, _10> ));
}
MPL_TEST_CASE()
{
MPL_ASSERT(( less_equal<_0, _10> ));
MPL_ASSERT_NOT(( less_equal<_10, _0> ));
MPL_ASSERT(( less_equal<_10, _10> ));
}
MPL_TEST_CASE()
{
MPL_ASSERT(( greater<_10, _0> ));
MPL_ASSERT_NOT(( greater<_0, _10> ));
MPL_ASSERT_NOT(( greater<_10, _10> ));
}
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( greater_equal<_0, _10> ));
MPL_ASSERT(( greater_equal<_10, _0> ));
MPL_ASSERT(( greater_equal<_10, _10> ));
}

View File

@@ -0,0 +1,24 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/contains.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector<int,char,long,short,char,long,double,long>::type types;
MPL_ASSERT(( contains< types,short > ));
MPL_ASSERT_NOT(( contains< types,unsigned > ));
}

211
libs/mpl/test/copy.cpp Normal file
View File

@@ -0,0 +1,211 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/copy.hpp>
#include <boost/mpl/vector/vector20_c.hpp>
#include <boost/mpl/vector/vector0.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/begin_end_fwd.hpp>
#include <boost/mpl/size_fwd.hpp>
#include <boost/mpl/empty_fwd.hpp>
#include <boost/mpl/front_fwd.hpp>
#include <boost/mpl/insert_fwd.hpp>
#include <boost/mpl/insert_range_fwd.hpp>
#include <boost/mpl/erase_fwd.hpp>
#include <boost/mpl/clear_fwd.hpp>
#include <boost/mpl/push_back_fwd.hpp>
#include <boost/mpl/pop_back_fwd.hpp>
#include <boost/mpl/back_fwd.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> answer;
typedef copy<
range_c<int,0,10>
, mpl::front_inserter< vector0<> >
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 10 );
MPL_ASSERT(( equal< result,answer > ));
}
MPL_TEST_CASE()
{
typedef vector10_c<int,10,11,12,13,14,15,16,17,18,19> numbers;
typedef reverse_copy<
range_c<int,0,10>
, mpl::front_inserter<numbers>
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 20 );
MPL_ASSERT(( equal< result,range_c<int,0,20> > ));
}
struct push_back_only_tag {};
template< typename Seq >
struct push_back_only
{
typedef push_back_only_tag tag;
typedef Seq seq;
};
namespace boost { namespace mpl {
template<>
struct begin_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: begin< typename Seq::seq >
{
};
};
template<>
struct end_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: end< typename Seq::seq >
{
};
};
template<>
struct size_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: size< typename Seq::seq >
{
};
};
template<>
struct empty_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: empty< typename Seq::seq >
{
};
};
template<>
struct front_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: front< typename Seq::seq >
{
};
};
template<>
struct insert_impl< ::push_back_only_tag >
{
template< typename Seq, typename Pos, typename X > struct apply
{
typedef ::push_back_only<
typename insert< typename Seq::seq, Pos, X >::type
> type;
};
};
template<>
struct insert_range_impl< ::push_back_only_tag >
{
template< typename Seq, typename Pos, typename X > struct apply
{
typedef ::push_back_only<
typename insert_range< typename Seq::seq, Pos, X >::type
> type;
};
};
template<>
struct erase_impl< ::push_back_only_tag >
{
template< typename Seq, typename Iter1, typename Iter2 > struct apply
{
typedef ::push_back_only<
typename erase< typename Seq::seq, Iter1, Iter2 >::type
> type;
};
};
template<>
struct clear_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
{
typedef ::push_back_only<
typename clear< typename Seq::seq >::type
> type;
};
};
template<>
struct push_back_impl< ::push_back_only_tag >
{
template< typename Seq, typename X > struct apply
{
typedef ::push_back_only<
typename push_back< typename Seq::seq, X >::type
> type;
};
};
template<>
struct pop_back_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
{
typedef ::push_back_only<
typename pop_back< typename Seq::seq >::type
> type;
};
};
template<>
struct back_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: back< typename Seq::seq >
{
};
};
template<>
struct has_push_back_impl< ::push_back_only_tag >
{
template< typename Seq > struct apply
: less< size<Seq>,int_<10> >
{
};
};
}}
MPL_TEST_CASE()
{
typedef vector10_c<int,0,1,2,3,4,5,6,7,8,9> numbers;
typedef copy< push_back_only< numbers > >::type result;
MPL_ASSERT((equal< numbers, result >));
}

54
libs/mpl/test/copy_if.cpp Normal file
View File

@@ -0,0 +1,54 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/copy_if.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list10_c<int,0,1,2,3,4,5,6,7,8,9>::type numbers;
typedef list5_c<int,4,3,2,1,0>::type answer;
typedef copy_if<
numbers
, less<_,int_<5> >
, mpl::front_inserter< list0_c<int> >
>::type result;
MPL_ASSERT_RELATION(size<result>::value, ==, 5);
MPL_ASSERT(( equal<result,answer> ));
}
MPL_TEST_CASE()
{
typedef list8<int,float,long,float,char,long,double,double>::type types;
typedef list4<float,float,double,double>::type float_types;
typedef reverse_copy_if<
types
, is_float<_>
, mpl::front_inserter< list0<> >
>::type result;
MPL_ASSERT_RELATION(mpl::size<result>::value, ==, 4);
MPL_ASSERT(( equal<result,float_types> ));
}

41
libs/mpl/test/count.cpp Normal file
View File

@@ -0,0 +1,41 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/count.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector<int,char,long,short,char,long,double,long> types;
MPL_ASSERT_RELATION( (count<types,int>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<types,double>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<types,char>::value), ==, 2 );
MPL_ASSERT_RELATION( (count<types,long>::value), ==, 3 );
MPL_ASSERT_RELATION( (count<types,unsigned>::value), ==, 0 );
}
MPL_TEST_CASE()
{
typedef vector_c<int,1,0,5,1,7,5,0,5> values;
MPL_ASSERT_RELATION( (count< values, integral_c<int,1> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,0> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,5> >::value), ==, 3 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,7> >::value), ==, 1 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,8> >::value), ==, 0 );
}

View File

@@ -0,0 +1,36 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/count_if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
typedef vector<int,char&,long,short,char&,long,double,long> types;
typedef vector_c<int,1,0,5,1,7,5,0,5> values;
MPL_ASSERT_RELATION( (count_if< types, boost::is_float<_> >::value), ==, 1 );
MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,char&> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,void*> >::value), ==, 0 );
MPL_ASSERT_RELATION( (count_if< values, less<_,int_<5> > >::value), ==, 4 );
MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<0>,_> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<-1>,_> >::value), ==, 0 );
}

92
libs/mpl/test/deque.cpp Normal file
View File

@@ -0,0 +1,92 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/deque.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/pop_back.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef deque<> d0;
typedef deque<char> d1;
typedef deque<char,long> d2;
typedef deque<char,char,char,char,char,char,char,char,int> d9;
MPL_ASSERT_RELATION( size<d0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<d1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<d2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<d9>::value, ==, 9 );
MPL_ASSERT(( empty<d0> ));
MPL_ASSERT_NOT(( empty<d1> ));
MPL_ASSERT_NOT(( empty<d2> ));
MPL_ASSERT_NOT(( empty<d9> ));
MPL_ASSERT(( is_same< front<d1>::type,char > ));
MPL_ASSERT(( is_same< back<d1>::type,char > ));
MPL_ASSERT(( is_same< front<d2>::type,char > ));
MPL_ASSERT(( is_same< back<d2>::type,long > ));
MPL_ASSERT(( is_same< front<d9>::type,char > ));
MPL_ASSERT(( is_same< back<d9>::type,int > ));
}
MPL_TEST_CASE()
{
typedef deque<char,long> d2;
typedef begin<d2>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
MPL_ASSERT(( is_same<deref<i1>::type,char> ));
MPL_ASSERT(( is_same<deref<i2>::type,long> ));
MPL_ASSERT(( is_same< i3, end<d2>::type > ));
}
MPL_TEST_CASE()
{
typedef deque<> d0;
typedef push_back<d0,int>::type d1;
MPL_ASSERT(( is_same< back<d1>::type,int > ));
typedef push_front<d1,char>::type d2;
MPL_ASSERT(( is_same< back<d2>::type,int > ));
MPL_ASSERT(( is_same< front<d2>::type,char > ));
typedef push_back<d2,long>::type d3;
MPL_ASSERT(( is_same< back<d3>::type,long > ));
}
MPL_TEST_CASE()
{
typedef deque<> d0;
typedef deque<char> d1;
typedef deque<char,long> d2;
typedef deque<char,char,char,char,char,char,char,char,int> d9;
MPL_ASSERT_RELATION( size<d0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<d1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<d2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<d9>::value, ==, 9 );
}

View File

@@ -0,0 +1,37 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<char,short,int,long>::type list;
typedef begin<list>::type first;
typedef end<list>::type last;
MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 4 );
}
MPL_TEST_CASE()
{
typedef range_c<int,0,10>::type range;
typedef begin<range>::type first;
typedef end<range>::type last;
MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 10 );
}

23
libs/mpl/test/empty.cpp Normal file
View File

@@ -0,0 +1,23 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/empty.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( empty< list0<> > ));
MPL_ASSERT_NOT(( empty< list1<char> > ));
}

View File

@@ -0,0 +1,39 @@
// Copyright Aleksey Gurtovoy 2004
// Copyright Alexander Nasonov 2004
//
// 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$
// $Revision$
#include <boost/mpl/empty_sequence.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_pointer.hpp>
MPL_TEST_CASE()
{
typedef begin<empty_sequence>::type begin;
typedef end<empty_sequence>::type end;
MPL_ASSERT(( is_same<begin,end> ));
MPL_ASSERT_RELATION( (mpl::distance<begin,end>::value), ==, 0 );
MPL_ASSERT_RELATION( size<empty_sequence>::value, ==, 0 );
typedef advance_c<begin,0>::type advanced;
MPL_ASSERT(( is_same<advanced,end> ));
MPL_ASSERT(( equal< empty_sequence, empty_sequence::type > ));
}

31
libs/mpl/test/equal.cpp Normal file
View File

@@ -0,0 +1,31 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/equal.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,float,long,double,char,long,double,float> list1;
typedef list<int,float,long,double,char,long,double,float> list2;
typedef list<int,float,long,double,char,long,double,short> list3;
typedef list<int,float,long,double,char,long,double> list4;
MPL_ASSERT(( equal<list1,list2> ));
MPL_ASSERT(( equal<list2,list1> ));
MPL_ASSERT_NOT(( equal<list2,list3> ));
MPL_ASSERT_NOT(( equal<list3,list4> ));
MPL_ASSERT_NOT(( equal<list4,list3> ));
}

45
libs/mpl/test/erase.cpp Normal file
View File

@@ -0,0 +1,45 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/erase.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,char,long,short,char,long,double,long> types;
typedef find<types,short>::type iter;
typedef erase<types, iter>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 7 );
typedef find<result,short>::type result_iter;
MPL_ASSERT(( is_same< result_iter, end<result>::type > ));
}
MPL_TEST_CASE()
{
typedef list_c<int,1,0,5,1,7,5,0,5> values;
typedef find< values, integral_c<int,7> >::type iter;
typedef erase<values, iter>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 7 );
typedef find<result, integral_c<int,7> >::type result_iter;
MPL_ASSERT(( is_same< result_iter, end<result>::type > ));
}

View File

@@ -0,0 +1,34 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/erase.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,char,long,short,unsigned,long,double,long> types;
typedef find<types,short>::type iter1;
typedef find<types,double>::type iter2;
typedef erase<types,iter1,iter2>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 5 );
typedef find<result,unsigned>::type iter;
MPL_ASSERT(( is_same< iter, end<result>::type > ));
}

33
libs/mpl/test/eval_if.cpp Normal file
View File

@@ -0,0 +1,33 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
typedef eval_if< true_, identity<char>, identity<long> >::type t1;
typedef eval_if_c< true, identity<char>, identity<long> >::type t2;
typedef eval_if< false_, identity<char>, identity<long> >::type t3;
typedef eval_if_c< false, identity<char>, identity<long> >::type t4;
MPL_ASSERT(( is_same<t1,char> ));
MPL_ASSERT(( is_same<t2,char> ));
MPL_ASSERT(( is_same<t3,long> ));
MPL_ASSERT(( is_same<t4,long> ));
}

View File

@@ -0,0 +1,42 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/static_assert.hpp>
#include <boost/mpl/filter_view.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,float,long,float,char[50],long double,char> types;
typedef mpl::list<float,float,long double> floats;
MPL_ASSERT(( equal< mpl::filter_view< types,boost::is_float<_> >::type,floats > ));
typedef mpl::max_element<
mpl::transform_view<
mpl::filter_view< types,boost::is_float<_> >
, mpl::sizeof_<_>
>
>::type iter;
MPL_ASSERT((is_same<mpl::deref<iter::base>::type, long double>));
}

37
libs/mpl/test/find.cpp Normal file
View File

@@ -0,0 +1,37 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/find.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,char,long,short,char,long,double,long>::type types;
typedef list_c<int,1,0,5,1,7,5,0,5> values;
typedef find<types, short>::type types_iter;
typedef find< values, integral_c<int,7> >::type values_iter;
MPL_ASSERT(( is_same< deref<types_iter>::type, short> ));
MPL_ASSERT_RELATION( deref<values_iter>::type::value, ==, 7 );
typedef begin<types>::type types_first;
typedef begin<values>::type values_first;
MPL_ASSERT_RELATION( (mpl::distance< types_first,types_iter >::value), ==, 3 );
MPL_ASSERT_RELATION( (mpl::distance< values_first,values_iter >::value), ==, 4 );
}

46
libs/mpl/test/find_if.cpp Normal file
View File

@@ -0,0 +1,46 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/find_if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
typedef vector<int,char,long,short,char,long,double,float,char>::type types;
typedef begin<types>::type first_;
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_float<_> >::type iter;
MPL_ASSERT(( is_same< iter::type, double > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 6 );
}
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,long> >::type iter;
MPL_ASSERT(( is_same< iter::type, long > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 2 );
}
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,void> >::type iter;
MPL_ASSERT(( is_same< iter, end<types>::type > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, size<types>::value );
}

55
libs/mpl/test/fold.cpp Normal file
View File

@@ -0,0 +1,55 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/fold.hpp>
#include <boost/mpl/reverse_fold.hpp>
//#include <boost/mpl/vector.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<long,float,short,double,float,long,long double> types;
typedef fold<
types
, int_<0>
, if_< boost::is_float<_2>,next<_1>,_1 >
>::type number_of_floats;
MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 );
}
MPL_TEST_CASE()
{
typedef list_c<int,5,-1,0,-7,-2,0,-5,4> numbers;
typedef list_c<int,-1,-7,-2,-5> negatives;
typedef reverse_fold<
numbers
, list_c<int>
, if_< less< _2,int_<0> >, push_front<_1,_2>, _1 >
>::type result;
MPL_ASSERT(( equal< result,negatives,equal_to<_1,_2> > ));
}

View File

@@ -0,0 +1,81 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <cassert>
namespace mpl = boost::mpl;
struct type_printer
{
type_printer(std::ostream& s) : f_stream(&s) {}
template< typename U > void operator()(mpl::identity<U>)
{
*f_stream << typeid(U).name() << '\n';
}
private:
std::ostream* f_stream;
};
struct value_printer
{
value_printer(std::ostream& s) : f_stream(&s) {}
template< typename U > void operator()(U x)
{
*f_stream << x << '\n';
}
private:
std::ostream* f_stream;
};
#ifdef __ICL
# pragma warning(disable:985)
#endif
void push_back(std::vector<int>* c, int i)
{
c->push_back(i);
}
int main()
{
typedef mpl::list<char,short,int,long,float,double> types;
mpl::for_each< types,mpl::make_identity<mpl::_1> >(type_printer(std::cout));
typedef mpl::range_c<int,0,10> numbers;
std::vector<int> v;
mpl::for_each<numbers>(
boost::bind(&push_back, &v, _1)
);
mpl::for_each< numbers >(value_printer(std::cout));
for (unsigned i = 0; i < v.size(); ++i)
assert(v[i] == (int)i);
return 0;
}

29
libs/mpl/test/front.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/front.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename Seq, int value > struct front_test
{
typedef typename front<Seq>::type t;
MPL_ASSERT_RELATION( t::value, ==, value );
};
MPL_TEST_CASE()
{
front_test< range_c<int,1,10>, 1 >();
front_test< range_c<int,2,10>, 2 >();
front_test< range_c<int,-1,0>, -1 >();
}

View File

@@ -0,0 +1,32 @@
// Copyright Sergey Krivonos 2017
//
// 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$
// $Revision$
#include <boost/mpl/get_tag.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/test/assert.hpp>
#include <boost/type_traits/is_same.hpp>
struct test_type_get_tag_def
{
typedef int a_tag;
};
BOOST_MPL_GET_TAG_DEF(a_tag);
MPL_TEST_CASE()
{
MPL_ASSERT(( is_same<int, boost::mpl::get_a_tag<test_type_get_tag_def>::type> ));
MPL_ASSERT(( is_same<test_type_get_tag_def::a_tag, boost::mpl::get_a_tag<test_type_get_tag_def>::type> ));
}

158
libs/mpl/test/has_xxx.cpp Normal file
View File

@@ -0,0 +1,158 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright Daniel Walker 2007
//
// 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$
// $Revision$
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <boost/mpl/aux_/test.hpp>
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(has_xxx_template, xxx, false)
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(yyy)
struct a1 {};
struct a2 { void xxx(); };
struct a3 { int xxx; };
struct a4 { static int xxx(); };
struct a5 { template< typename T > struct xxx {}; };
struct b1 { typedef int xxx; };
struct b2 { struct xxx; };
struct b3 { typedef int& xxx; };
struct b4 { typedef int* xxx; };
struct b5 { typedef int xxx[10]; };
struct b6 { typedef void (*xxx)(); };
struct b7 { typedef void (xxx)(); };
struct c1 { template< typename T > struct xxx {}; };
struct c2 { template< typename T1, typename T2 > struct xxx {}; };
struct c3 { template< typename T1, typename T2, typename T3 > struct xxx {}; };
struct c4 { template< typename T1, typename T2, typename T3, typename T4 > struct xxx {}; };
struct c5 { template< typename T1, typename T2, typename T3, typename T4, typename T5 > struct xxx {}; };
struct c6 { template< typename T > struct yyy {}; };
struct c7 { template< typename T1, typename T2 > struct yyy {}; };
template< typename T > struct outer;
template< typename T > struct inner { typedef typename T::type type; };
// agurt, 15/aug/04: make sure MWCW passes the test in presence of the following
// template
template< typename T > struct xxx;
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( has_xxx<int> ));
MPL_ASSERT_NOT(( has_xxx_template<int> ));
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
MPL_ASSERT_NOT(( has_xxx<int&> ));
MPL_ASSERT_NOT(( has_xxx_template<int&> ));
MPL_ASSERT_NOT(( has_xxx<int*> ));
MPL_ASSERT_NOT(( has_xxx_template<int*> ));
MPL_ASSERT_NOT(( has_xxx<int[]> ));
MPL_ASSERT_NOT(( has_xxx_template<int[]> ));
MPL_ASSERT_NOT(( has_xxx<int (*)()> ));
MPL_ASSERT_NOT(( has_xxx_template<int (*)()> ));
MPL_ASSERT_NOT(( has_xxx<a2> ));
MPL_ASSERT_NOT(( has_xxx_template<a2> ));
MPL_ASSERT_NOT(( has_xxx<a3> ));
MPL_ASSERT_NOT(( has_xxx_template<a3> ));
MPL_ASSERT_NOT(( has_xxx<a4> ));
MPL_ASSERT_NOT(( has_xxx_template<a4> ));
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
MPL_ASSERT_NOT(( has_xxx<a5> ));
MPL_ASSERT(( has_xxx_template<a5> ));
#endif
MPL_ASSERT_NOT(( has_xxx< enum_ > ));
MPL_ASSERT_NOT(( has_xxx_template< enum_ > ));
#endif
MPL_ASSERT_NOT(( has_xxx<a1> ));
MPL_ASSERT_NOT(( has_xxx_template<a1> ));
MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > ));
MPL_ASSERT_NOT(( has_xxx_template< outer< inner<int> > > ));
MPL_ASSERT_NOT(( has_xxx< incomplete > ));
MPL_ASSERT_NOT(( has_xxx_template< incomplete > ));
MPL_ASSERT_NOT(( has_xxx< abstract > ));
MPL_ASSERT_NOT(( has_xxx_template< abstract > ));
MPL_ASSERT_NOT(( has_xxx< noncopyable > ));
MPL_ASSERT_NOT(( has_xxx_template< noncopyable > ));
#if !BOOST_WORKAROUND(__COMO_VERSION__, BOOST_TESTED_AT(4308))
MPL_ASSERT_NOT(( has_xxx_template<b1> ));
MPL_ASSERT_NOT(( has_xxx_template<b2> ));
MPL_ASSERT_NOT(( has_xxx_template<b3> ));
MPL_ASSERT_NOT(( has_xxx_template<b4> ));
MPL_ASSERT_NOT(( has_xxx_template<b5> ));
MPL_ASSERT_NOT(( has_xxx_template<b6> ));
MPL_ASSERT_NOT(( has_xxx_template<b7> ));
#endif
// Same name, different args.
MPL_ASSERT(( has_xxx_template<c1> ));
MPL_ASSERT(( has_xxx_template<c2> ));
MPL_ASSERT(( has_xxx_template<c3> ));
MPL_ASSERT(( has_xxx_template<c4> ));
MPL_ASSERT(( has_xxx_template<c5> ));
MPL_ASSERT(( has_yyy<c6> ));
MPL_ASSERT(( has_yyy<c7> ));
// Different name, different args.
MPL_ASSERT_NOT(( has_xxx_template<c6> ));
MPL_ASSERT_NOT(( has_xxx_template<c7> ));
MPL_ASSERT_NOT(( has_yyy<c1> ));
MPL_ASSERT_NOT(( has_yyy<c2> ));
MPL_ASSERT_NOT(( has_yyy<c3> ));
MPL_ASSERT_NOT(( has_yyy<c4> ));
MPL_ASSERT_NOT(( has_yyy<c5> ));
MPL_ASSERT(( has_xxx<b1,true_> ));
MPL_ASSERT(( has_xxx<b2,true_> ));
MPL_ASSERT(( has_xxx<b3,true_> ));
MPL_ASSERT(( has_xxx<b4,true_> ));
MPL_ASSERT(( has_xxx<b5,true_> ));
MPL_ASSERT(( has_xxx<b6,true_> ));
MPL_ASSERT(( has_xxx<b7,true_> ));
MPL_ASSERT(( has_xxx_template<c1,true_> ));
#if !defined(HAS_XXX_ASSERT)
# define HAS_XXX_ASSERT(x) MPL_ASSERT(x)
#endif
HAS_XXX_ASSERT(( has_xxx<b1> ));
HAS_XXX_ASSERT(( has_xxx<b2> ));
HAS_XXX_ASSERT(( has_xxx<b3> ));
HAS_XXX_ASSERT(( has_xxx<b4> ));
HAS_XXX_ASSERT(( has_xxx<b5> ));
HAS_XXX_ASSERT(( has_xxx<b6> ));
HAS_XXX_ASSERT(( has_xxx<b7> ));
#if !defined(HAS_XXX_TEMPLATE_ASSERT)
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT(x)
#endif
HAS_XXX_TEMPLATE_ASSERT(( has_xxx_template<c1> ));
}

View File

@@ -0,0 +1,32 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef apply1< identity<>, char >::type t1;
typedef apply1< identity<_1>, int >::type t2;
MPL_ASSERT(( is_same< t1, char > ));
MPL_ASSERT(( is_same< t2, int > ));
}
MPL_TEST_CASE()
{
typedef apply1< make_identity<>, char >::type t1;
typedef apply1< make_identity<_1>, int >::type t2;
MPL_ASSERT(( is_same< t1, identity<char> > ));
MPL_ASSERT(( is_same< t2, identity<int> > ));
}

29
libs/mpl/test/if.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef if_<true_,char,long>::type t1;
typedef if_c<true,char,long>::type t2;
typedef if_<false_,char,long>::type t3;
typedef if_c<false,char,long>::type t4;
MPL_ASSERT(( is_same<t1, char> ));
MPL_ASSERT(( is_same<t2, char> ));
MPL_ASSERT(( is_same<t3, long> ));
MPL_ASSERT(( is_same<t4, long> ));
}

View File

@@ -0,0 +1,34 @@
// Copyright Eric Friedman 2003
//
// 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$
// $Revision$
#include <boost/mpl/index_of.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/void.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list< int, double, float >::type types;
typedef index_of< types, int >::type index_of_int;
typedef index_of< types, double >::type index_of_double;
typedef index_of< types, float >::type index_of_float;
typedef index_of< types, char >::type index_of_char;
MPL_ASSERT_RELATION( index_of_int::value, ==, 0 );
MPL_ASSERT_RELATION( index_of_double::value, ==, 1 );
MPL_ASSERT_RELATION( index_of_float::value, ==, 2 );
MPL_ASSERT(( is_void_< index_of_char > ));
}

40
libs/mpl/test/inherit.cpp Normal file
View File

@@ -0,0 +1,40 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/aux_/test.hpp>
struct her { typedef her herself; };
struct my { typedef my myself; };
MPL_TEST_CASE()
{
MPL_ASSERT(( is_same<inherit<her>::type, her> ));
typedef inherit<her,my>::type her_my1;
MPL_ASSERT(( is_same<her_my1::herself, her> ));
MPL_ASSERT(( is_same<her_my1::myself, my> ));
typedef inherit<empty_base,her>::type her1;
MPL_ASSERT(( is_same<her1, her> ));
typedef inherit<empty_base,her,empty_base,empty_base>::type her2;
MPL_ASSERT(( is_same<her2, her> ));
typedef inherit<her,empty_base,my>::type her_my2;
MPL_ASSERT(( is_same<her_my2::herself, her> ));
MPL_ASSERT(( is_same<her_my2::myself, my> ));
typedef inherit<empty_base,empty_base>::type empty;
MPL_ASSERT(( is_same<empty, empty_base> ));
}

31
libs/mpl/test/insert.cpp Normal file
View File

@@ -0,0 +1,31 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/insert.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector_c<int,0,1,3,4,5,6,7,8,9> numbers;
typedef find< numbers,integral_c<int,3> >::type pos;
typedef insert< numbers,pos,integral_c<int,2> >::type range;
MPL_ASSERT_RELATION( size<range>::value, ==, 10 );
MPL_ASSERT(( equal< range,range_c<int,0,10> > ));
}

View File

@@ -0,0 +1,73 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/set.hpp>
#include <boost/mpl/set_c.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector_c<int,0,1,7,8,9> numbers;
typedef find< numbers,integral_c<int,7> >::type pos;
typedef insert_range< numbers,pos,range_c<int,2,7> >::type range;
MPL_ASSERT_RELATION( size<range>::value, ==, 10 );
MPL_ASSERT(( equal< range,range_c<int,0,10> > ));
typedef insert_range< list0<>,end< list0<> >::type,list1<int> >::type result2;
MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
}
template<typename A, typename B>
void test_associative()
{
typedef typename insert_range< A,typename end< A >::type,B >::type C;
MPL_ASSERT_RELATION( size<C>::value, <=, (size<A>::value + size<B>::value) );
MPL_ASSERT(( fold< joint_view< A,B >,true_,and_< _1,contains< C,_2 > > > ));
}
MPL_TEST_CASE()
{
typedef set3< short,int,long > signed_integers;
typedef set3< unsigned short,unsigned int,unsigned long > unsigned_integers;
test_associative<signed_integers, unsigned_integers>();
typedef set_c< int,1,3,5,7,9 > odds;
typedef set_c< int,0,2,4,6,8 > evens;
test_associative<odds, evens>();
typedef map2<
pair< void,void* >
, pair< int,int* >
> pointers;
typedef map2<
pair< void const,void const* >
, pair< int const,int const* >
> pointers_to_const;
test_associative<pointers, pointers_to_const>();
}

24
libs/mpl/test/int.cpp Normal file
View File

@@ -0,0 +1,24 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/int.hpp>
#include <boost/preprocessor/repeat.hpp>
#include "integral_wrapper_test.hpp"
MPL_TEST_CASE()
{
# define WRAPPER(T, i) int_<i>
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
}

View File

@@ -0,0 +1,30 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/integral_c.hpp>
#include <boost/preprocessor/repeat.hpp>
#include "integral_wrapper_test.hpp"
MPL_TEST_CASE()
{
# define WRAPPER(T, i) integral_c<T,i>
#if !(defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3))
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char)
#endif
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, short)
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, long)
}

View File

@@ -0,0 +1,63 @@
// Copyright Aleksey Gurtovoy 2001-2006
//
// 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$
// $Revision$
#include <boost/mpl/next_prior.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <cassert>
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
BOOST_TEST(( WRAPPER(T,i)() == i )); \
BOOST_TEST(( WRAPPER(T,i)::value == i )); \
/**/
#else
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
BOOST_TEST(( WRAPPER(T,i)::value == i )); \
/**/
#endif
#if defined(BOOST_NO_CXX11_CONSTEXPR)
#define CONSTEXPR_INTEGRAL_TEST(T, i)
#else
#define CONSTEXPR_INTEGRAL_TEST(T, i) { static_assert(T() == i, "Constexpr for integral constant failed"); }
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// agurt 20/nov/06: see http://article.gmane.org/gmane.comp.lib.boost.devel/151065
#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
{ \
typedef WRAPPER(T,i) borland_tested_type; \
{ typedef is_same< borland_tested_type::value_type, T > borland_test_type; \
MPL_ASSERT(( borland_test_type )); } \
{ MPL_ASSERT(( is_same< borland_tested_type::type, WRAPPER(T,i) > )); } \
{ MPL_ASSERT(( is_same< next< borland_tested_type >::type, WRAPPER(T,i+1) > )); } \
{ MPL_ASSERT(( is_same< prior< borland_tested_type >::type, WRAPPER(T,i-1) > )); } \
{ MPL_ASSERT_RELATION( (borland_tested_type::value), ==, i ); } \
CONSTEXPR_INTEGRAL_TEST(borland_tested_type, i) \
INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
} \
/**/
#else
#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::value_type, T > )); } \
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::type, WRAPPER(T,i) > )); } \
{ MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \
{ MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \
{ MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \
CONSTEXPR_INTEGRAL_TEST(WRAPPER(T,i), i) \
INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
/**/
#endif

View File

@@ -0,0 +1,42 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/is_placeholder.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/cat.hpp>
#define AUX_IS_PLACEHOLDER_TEST(unused1, n, unused2) \
{ MPL_ASSERT(( is_placeholder< \
BOOST_PP_CAT(_,BOOST_PP_INC(n)) \
> )); } \
/**/
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( is_placeholder<int> ));
MPL_ASSERT_NOT(( is_placeholder<UDT> ));
MPL_ASSERT_NOT(( is_placeholder<incomplete> ));
MPL_ASSERT_NOT(( is_placeholder<abstract> ));
MPL_ASSERT_NOT(( is_placeholder<noncopyable> ));
MPL_ASSERT(( is_placeholder<_> ));
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, AUX_IS_PLACEHOLDER_TEST
, unused
)
}

View File

@@ -0,0 +1,39 @@
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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$
// $Revision$
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct std_vector
{
T* begin();
};
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( is_sequence< std_vector<int> > ));
MPL_ASSERT_NOT(( is_sequence< int_<0> > ));
MPL_ASSERT_NOT(( is_sequence< int > ));
MPL_ASSERT_NOT(( is_sequence< int& > ));
MPL_ASSERT_NOT(( is_sequence< UDT > ));
MPL_ASSERT_NOT(( is_sequence< UDT* > ));
MPL_ASSERT(( is_sequence< range_c<int,0,0> > ));
MPL_ASSERT(( is_sequence< list<> > ));
MPL_ASSERT(( is_sequence< list<int> > ));
MPL_ASSERT(( is_sequence< vector<> > ));
MPL_ASSERT(( is_sequence< vector<int> > ));
}

View File

@@ -0,0 +1,23 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/iterator_tags.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( less<mpl::forward_iterator_tag,mpl::bidirectional_iterator_tag> ));
MPL_ASSERT(( less<mpl::bidirectional_iterator_tag,mpl::random_access_iterator_tag> ));
}

View File

@@ -0,0 +1,56 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef joint_view<
range_c<int,0,10>
, range_c<int,10,15>
> numbers;
typedef range_c<int,0,15> answer;
MPL_ASSERT(( equal<numbers,answer> ));
MPL_ASSERT(( equal<numbers::type,answer> ));
MPL_ASSERT_RELATION( size<numbers>::value, ==, 15 );
}
template< typename View > struct test_is_empty
{
typedef typename begin<View>::type first_;
typedef typename end<View>::type last_;
MPL_ASSERT_RELATION( size<View>::value, ==, 0 );
MPL_ASSERT(( is_same< first_,last_> ));
MPL_ASSERT_INSTANTIATION( View );
MPL_ASSERT_INSTANTIATION( first_ );
MPL_ASSERT_INSTANTIATION( last_ );
};
MPL_TEST_CASE()
{
test_is_empty< joint_view< list0<>,list0<> > >();
test_is_empty< joint_view< list<>,list0<> > >();
test_is_empty< joint_view< list<>,list<> > >();
test_is_empty< joint_view< list<>, joint_view< list0<>,list0<> > > >();
}

78
libs/mpl/test/lambda.cpp Normal file
View File

@@ -0,0 +1,78 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/logical.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_float.hpp>
struct my
{
char a[100];
};
MPL_TEST_CASE()
{
// !(x == char) && !(x == double) || sizeof(x) > 8
typedef lambda<
or_<
and_<
not_< boost::is_same<_1, char> >
, not_< boost::is_float<_1> >
>
, greater< sizeof_<_1>, mpl::size_t<8> >
>
>::type f;
MPL_ASSERT_NOT(( apply_wrap1<f,char> ));
MPL_ASSERT_NOT(( apply_wrap1<f,double> ));
MPL_ASSERT(( apply_wrap1<f,long> ));
MPL_ASSERT(( apply_wrap1<f,my> ));
}
MPL_TEST_CASE()
{
// x == y || x == my || sizeof(x) == sizeof(y)
typedef lambda<
or_<
boost::is_same<_1, _2>
, boost::is_same<_2, my>
, equal_to< sizeof_<_1>, sizeof_<_2> >
>
>::type f;
MPL_ASSERT_NOT(( apply_wrap2<f,double,char> ));
MPL_ASSERT_NOT(( apply_wrap2<f,my,int> ));
MPL_ASSERT_NOT(( apply_wrap2<f,my,char[99]> ));
MPL_ASSERT(( apply_wrap2<f,int,int> ));
MPL_ASSERT(( apply_wrap2<f,my,my> ));
MPL_ASSERT(( apply_wrap2<f,signed long, unsigned long> ));
}
MPL_TEST_CASE()
{
// bind <-> lambda interaction
typedef lambda< less<_1,_2> >::type pred;
typedef bind2< pred, _1, int_<4> > f;
MPL_ASSERT(( apply_wrap1< f,int_<3> > ));
}

View File

@@ -0,0 +1,48 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/gcc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
typedef int UDT::* mem_ptr;
typedef int (UDT::* mem_fun_ptr)();
#define AUX_LAMBDA_TEST(T) \
{ MPL_ASSERT(( apply1<lambda< is_same<_,T> >::type, T> )); } \
{ MPL_ASSERT(( apply1<lambda< is_same<T,_> >::type, T> )); } \
{ MPL_ASSERT(( apply2<lambda< is_same<_,_> >::type, T, T> )); } \
/**/
MPL_TEST_CASE()
{
AUX_LAMBDA_TEST( UDT );
AUX_LAMBDA_TEST( abstract );
AUX_LAMBDA_TEST( noncopyable );
AUX_LAMBDA_TEST( incomplete );
AUX_LAMBDA_TEST( int );
AUX_LAMBDA_TEST( void );
AUX_LAMBDA_TEST( double );
AUX_LAMBDA_TEST( int& );
AUX_LAMBDA_TEST( int* );
#if !BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \
&& !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
AUX_LAMBDA_TEST( int[] );
#endif
AUX_LAMBDA_TEST( int[10] );
AUX_LAMBDA_TEST( int (*)() )
AUX_LAMBDA_TEST( mem_ptr );
AUX_LAMBDA_TEST( mem_fun_ptr );
}

68
libs/mpl/test/list.cpp Normal file
View File

@@ -0,0 +1,68 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/list.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list0<> l0;
typedef list1<char> l1;
typedef list2<char,long> l2;
typedef list9<char,char,char,char,char,char,char,char,char> l9;
MPL_ASSERT_RELATION(size<l0>::value, ==, 0);
MPL_ASSERT_RELATION(size<l1>::value, ==, 1);
MPL_ASSERT_RELATION(size<l2>::value, ==, 2);
MPL_ASSERT_RELATION(size<l9>::value, ==, 9);
MPL_ASSERT(( empty<l0> ));
MPL_ASSERT_NOT(( empty<l1> ));
MPL_ASSERT_NOT(( empty<l2> ));
MPL_ASSERT_NOT(( empty<l9> ));
MPL_ASSERT(( is_same<front<l1>::type,char> ));
MPL_ASSERT(( is_same<front<l2>::type,char> ));
MPL_ASSERT(( is_same<front<l9>::type,char> ));
}
MPL_TEST_CASE()
{
typedef list2<char,long> l2;
typedef begin<l2>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
MPL_ASSERT(( is_same<deref<i1>::type,char> ));
MPL_ASSERT(( is_same<deref<i2>::type,long> ));
MPL_ASSERT(( is_same< i3, end<l2>::type > ));
}
MPL_TEST_CASE()
{
typedef list0<> l0;
typedef push_front<l0,char>::type l1;
MPL_ASSERT(( is_same<front<l1>::type,char> ));
typedef push_front<l1,long>::type l2;
MPL_ASSERT(( is_same<front<l2>::type,long> ));
}

81
libs/mpl/test/list_c.cpp Normal file
View File

@@ -0,0 +1,81 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/static_assert.hpp>
#include <boost/mpl/aux_/test.hpp>
#if !BOOST_WORKAROUND(BOOST_MSVC,<= 1200)
MPL_TEST_CASE()
{
typedef list_c<bool,true>::type l1;
typedef list_c<bool,false>::type l2;
MPL_ASSERT(( is_same< l1::value_type, bool > ));
MPL_ASSERT(( is_same< l2::value_type, bool > ));
MPL_ASSERT_RELATION( front<l1>::type::value, ==, true );
MPL_ASSERT_RELATION( front<l2>::type::value, ==, false );
}
#endif
MPL_TEST_CASE()
{
typedef list_c<int,-1>::type l1;
typedef list_c<int,0,1>::type l2;
typedef list_c<int,1,2,3>::type l3;
MPL_ASSERT(( is_same< l1::value_type, int > ));
MPL_ASSERT(( is_same< l2::value_type, int > ));
MPL_ASSERT(( is_same< l3::value_type, int > ));
MPL_ASSERT_RELATION( size<l1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<l2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<l3>::value, ==, 3 );
MPL_ASSERT_RELATION( front<l1>::type::value, ==, -1 );
MPL_ASSERT_RELATION( front<l2>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<l3>::type::value, ==, 1 );
}
MPL_TEST_CASE()
{
typedef list_c<unsigned,0>::type l1;
typedef list_c<unsigned,1,2>::type l2;
MPL_ASSERT(( is_same< l1::value_type, unsigned > ));
MPL_ASSERT(( is_same< l2::value_type, unsigned > ));
MPL_ASSERT_RELATION( size<l1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<l2>::value, ==, 2 );
MPL_ASSERT_RELATION( front<l1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<l2>::type::value, ==, 1 );
}
MPL_TEST_CASE()
{
typedef list_c<unsigned,2,1> l2;
MPL_ASSERT(( is_same< l2::value_type, unsigned > ));
typedef begin<l2>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
MPL_ASSERT_RELATION( deref<i1>::type::value, ==, 2 );
MPL_ASSERT_RELATION( deref<i2>::type::value, ==, 1 );
MPL_ASSERT(( is_same< i3, end<l2>::type > ));
}

41
libs/mpl/test/logical.cpp Normal file
View File

@@ -0,0 +1,41 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/logical.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
struct unknown;
using mpl::true_;
using mpl::false_;
MPL_TEST_CASE()
{
MPL_ASSERT(( mpl::and_< true_,true_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,true_ > ));
MPL_ASSERT_NOT(( mpl::and_< true_,false_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,false_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,unknown > ));
MPL_ASSERT_NOT(( mpl::and_< false_,unknown,unknown > ));
MPL_ASSERT(( mpl::or_< true_,true_ > ));
MPL_ASSERT(( mpl::or_< false_,true_ > ));
MPL_ASSERT(( mpl::or_< true_,false_ > ));
MPL_ASSERT_NOT(( mpl::or_< false_,false_ > ));
MPL_ASSERT(( mpl::or_< true_,unknown > ));
MPL_ASSERT(( mpl::or_< true_,unknown,unknown > ));
MPL_ASSERT_NOT(( mpl::not_< true_ > ));
MPL_ASSERT(( mpl::not_< false_ > ));
}

View File

@@ -0,0 +1,28 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/lower_bound.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list_c<int,1,2,3,3,3,5,8> numbers;
typedef lower_bound< numbers, int_<4> >::type iter;
MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 );
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}

235
libs/mpl/test/map.cpp Normal file
View File

@@ -0,0 +1,235 @@
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/map.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/has_key.hpp>
#include <boost/mpl/order.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef map2<
mpl::pair<int,unsigned>
, mpl::pair<char,unsigned char>
> m_;
typedef erase_key<m_,char>::type m;
MPL_ASSERT_RELATION( size<m>::type::value, ==, 1 );
MPL_ASSERT_NOT(( empty<m> ));
MPL_ASSERT(( is_same< clear<m>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m,char>::type,void_ > ));
MPL_ASSERT(( contains< m,mpl::pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m,mpl::pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m,mpl::pair<char,unsigned char> > ));
MPL_ASSERT_NOT(( has_key<m,char>::type ));
MPL_ASSERT(( has_key<m,int>::type ));
MPL_ASSERT_NOT(( is_same< order<m,int>::type, void_ > ));
MPL_ASSERT(( is_same< order<m,char>::type,void_ > ));
typedef begin<m>::type first;
typedef end<m>::type last;
MPL_ASSERT(( is_same< deref<first>::type,mpl::pair<int,unsigned> > ));
MPL_ASSERT(( is_same< next<first>::type,last > ));
typedef insert<m,mpl::pair<char,long> >::type m2;
MPL_ASSERT_RELATION( size<m2>::type::value, ==, 2 );
MPL_ASSERT_NOT(( empty<m2>::type ));
MPL_ASSERT(( is_same< clear<m2>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m2,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m2,char>::type,long > ));
MPL_ASSERT(( contains< m2,mpl::pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m2,mpl::pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m2,mpl::pair<char,unsigned char> > ));
MPL_ASSERT(( contains< m2,mpl::pair<char,long> > ));
MPL_ASSERT(( has_key<m2,char>::type ));
MPL_ASSERT_NOT(( has_key<m2,long>::type ));
MPL_ASSERT_NOT(( is_same< order<m2,int>::type, void_ > ));
MPL_ASSERT_NOT(( is_same< order<m2,char>::type, void_ > ));
MPL_ASSERT_NOT(( is_same< order<m2,char>::type, order<m2,int>::type > ));
typedef begin<m2>::type first2;
typedef end<m2>::type last2;
MPL_ASSERT(( is_same<deref<first2>::type,mpl::pair<int,unsigned> > ));
typedef next<first2>::type iter;
MPL_ASSERT(( is_same<deref<iter>::type,mpl::pair<char,long> > ));
MPL_ASSERT(( is_same< next<iter>::type,last2 > ));
typedef insert<m2,mpl::pair<int,unsigned> >::type s2_1;
MPL_ASSERT(( is_same<m2,s2_1> ));
typedef insert<m2,mpl::pair<long,unsigned> >::type m3;
MPL_ASSERT_RELATION( size<m3>::type::value, ==, 3 );
MPL_ASSERT(( has_key<m3,long>::type ));
MPL_ASSERT(( has_key<m3,int>::type ));
MPL_ASSERT(( has_key<m3,char>::type ));
MPL_ASSERT(( contains< m3,mpl::pair<long,unsigned> > ));
MPL_ASSERT(( contains< m3,mpl::pair<int,unsigned> > ));
typedef insert<m,mpl::pair<char,long> >::type m1;
MPL_ASSERT_RELATION( size<m1>::type::value, ==, 2 );
MPL_ASSERT(( is_same< at<m1,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m1,char>::type,long > ));
MPL_ASSERT(( contains< m1,mpl::pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m1,mpl::pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m1,mpl::pair<char,unsigned char> > ));
MPL_ASSERT(( contains< m1,mpl::pair<char,long> > ));
MPL_ASSERT(( is_same< m1,m2 > ));
typedef erase_key<m1,char>::type m_1;
MPL_ASSERT(( is_same<m,m_1> ));
MPL_ASSERT_RELATION( size<m_1>::type::value, ==, 1 );
MPL_ASSERT(( is_same< at<m_1,char>::type,void_ > ));
MPL_ASSERT(( is_same< at<m_1,int>::type,unsigned > ));
typedef erase_key<m3,char>::type m2_1;
MPL_ASSERT_RELATION( size<m2_1>::type::value, ==, 2 );
MPL_ASSERT(( is_same< at<m2_1,char>::type,void_ > ));
MPL_ASSERT(( is_same< at<m2_1,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m2_1,long>::type,unsigned > ));
}
MPL_TEST_CASE()
{
typedef map0<> m;
MPL_ASSERT_RELATION( size<m>::type::value, ==, 0 );
MPL_ASSERT(( empty<m>::type ));
MPL_ASSERT(( is_same< clear<m>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m,char>::type,void_ > ));
MPL_ASSERT_NOT(( has_key<m,char>::type ));
MPL_ASSERT_NOT(( has_key<m,int>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete>::type ));
MPL_ASSERT_NOT(( has_key<m,char const>::type ));
MPL_ASSERT_NOT(( has_key<m,int const>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT const>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete const>::type ));
MPL_ASSERT_NOT(( has_key<m,int*>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT*>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete*>::type ));
MPL_ASSERT_NOT(( has_key<m,int&>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT&>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete&>::type ));
typedef insert<m,mpl::pair<char,int> >::type m1;
MPL_ASSERT_RELATION( size<m1>::type::value, ==, 1 );
MPL_ASSERT(( is_same< at<m1,char>::type,int > ));
typedef erase_key<m,char>::type m0_1;
MPL_ASSERT_RELATION( size<m0_1>::type::value, ==, 0 );
MPL_ASSERT(( is_same< at<m0_1,char>::type,void_ > ));
}
// Use a template for testing so that GCC will show us the actual types involved
template <class M>
void test()
{
MPL_ASSERT_RELATION( size<M>::value, ==, 3 );
typedef typename end<M>::type not_found;
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<int,int*> >::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<long,long*> >::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<char,char*> >::type,not_found> ));
BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<M,int>::type,not_found> ));
};
MPL_TEST_CASE()
{
typedef map< mpl::pair<int,int*> > map_of_1_pair;
typedef begin<map_of_1_pair>::type iter_to_1_pair;
BOOST_MPL_ASSERT((
is_same<
deref<iter_to_1_pair>::type
, mpl::pair<int,int*>
>
));
typedef map<
mpl::pair<int,int*>
, mpl::pair<long,long*>
, mpl::pair<char,char*>
> mymap;
test<mymap>();
test<mymap::type>();
}
MPL_TEST_CASE()
{
typedef mpl::erase_key<
mpl::map<
mpl::pair<char, double>
, mpl::pair<int, float>
>
, char
>::type int_to_float_map;
typedef mpl::insert<
int_to_float_map
, mpl::pair<char, long>
>::type with_char_too;
BOOST_MPL_ASSERT((
boost::is_same<
mpl::at<with_char_too, char>::type
, long
>
));
}
MPL_TEST_CASE()
{
typedef insert< map<>, pair<int,int> >::type little_map;
MPL_ASSERT_RELATION(size<little_map>::value, ==, 1);
MPL_ASSERT_RELATION(size<little_map::type>::value, ==, 1);
}
MPL_TEST_CASE()
{
typedef erase_key< map< pair<float,float>, pair<int,int> >, float >::type little_map;
MPL_ASSERT_RELATION(size<little_map>::value, ==, 1);
MPL_ASSERT_RELATION(size<little_map::type>::value, ==, 1);
}

View File

@@ -0,0 +1,26 @@
// Copyright Eric Friedman 2002-2003
//
// 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$
// $Revision$
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list_c<int,3,4,2,0,-5,8,-1,7>::type numbers;
typedef max_element< numbers >::type iter;
typedef deref<iter>::type max_value;
MPL_ASSERT_RELATION( max_value::value, ==, 8 );
}

27
libs/mpl/test/min_max.cpp Normal file
View File

@@ -0,0 +1,27 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/min_max.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( is_same< mpl::min< int_<5>,int_<7> >::type,int_<5> > ));
MPL_ASSERT(( is_same< mpl::max< int_<5>,int_<7> >::type,int_<7> > ));
MPL_ASSERT(( is_same< mpl::min< int_<-5>,int_<-7> >::type,int_<-7> > ));
MPL_ASSERT(( is_same< mpl::max< int_<-5>,int_<-7> >::type,int_<-5> > ));
}

107
libs/mpl/test/multiset.cpp Normal file
View File

@@ -0,0 +1,107 @@
// Copyright Aleksey Gurtovoy 2003-2006
//
// 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$
// $Revision$
#include <boost/mpl/multiset/multiset0.hpp>
//#include <boost/mpl/multiset/multiset10.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/count.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/find.hpp>
#include <boost/config.hpp>
/*
struct test_data1
{
typedef multiset0<> s0;
typedef multiset1<int> s1;
typedef multiset2<int,char&> s2;
typedef multiset3<int,char&,int> s3;
typedef multiset4<int,char&,int,abstract> s4;
};
struct test_data2
{
typedef multiset<> s0;
typedef multiset<int> s1;
typedef multiset<int,char&> s2;
typedef multiset<int,char&,int> s3;
typedef multiset<int,char&,int,abstract> s4;
};
*/
template< typename S0 >
struct test_data
{
typedef S0 s0;
typedef typename insert<s0,int>::type s1;
typedef typename insert<s1,char&>::type s2;
typedef typename insert<s2,int>::type s3;
typedef typename insert<s3,abstract>::type s4;
};
template< typename T >
void count_test()
{
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s0,int>::value ), ==, 0 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s1,int>::value ), ==, 1 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,int>::value ), ==, 1 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,char&>::value ), ==, 1 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,int>::value ), ==, 2 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,char&>::value ), ==, 1 );
MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s4,abstract>::value ), ==, 1 );
}
MPL_TEST_CASE()
{
//count_test<test_data1>();
//count_test<test_data2>();
//count_test< test_data< multiset<> > >();
count_test< test_data< multiset0<> > >();
}
/*
// Use a template for testing so that GCC will show us the actual types involved
template <class S>
void find_test()
{
BOOST_MPL_ASSERT_RELATION( size<S>::value, ==, 3 );
typedef typename end<S>::type not_found;
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,int>::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,long>::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char>::type,not_found> ));
BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char*>::type,not_found> ));
}
*/
MPL_TEST_CASE()
{
// agurt 11/jun/06: multiset does not implement iterators yet!
// typedef insert<multiset0<>, int>::type set_of_1_int;
// typedef begin<set_of_1_int>::type iter_to_1_int;
// BOOST_MPL_ASSERT(( is_same< deref<iter_to_1_int>::type, int > ));
typedef multiset0<> s0;
typedef insert<s0,int>::type s1;
typedef insert<s1,long>::type s2;
typedef insert<s2,char>::type myset;
// find_test<myset>();
// find_test<myset::type>();
}

29
libs/mpl/test/next.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/next.hpp>
#include <boost/mpl/prior.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef int_<0> _0;
typedef int_<1> _1;
typedef int_<2> _2;
MPL_ASSERT(( is_same< next<_0>::type, _1 > ));
MPL_ASSERT(( is_same< next<_1>::type, _2 > ));
MPL_ASSERT(( is_same< prior<_1>::type, _0 > ));
MPL_ASSERT(( is_same< prior<_2>::type, _1 > ));
}

View File

@@ -0,0 +1,30 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003
//
// 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$
// $Revision$
// This file tests that we have the right value for
// BOOST_MPL_CFG_NO_HAS_XXX, and that 'has_xxx' doesn't just fail to
// compile arbitrarily.
#include <boost/mpl/aux_/config/has_xxx.hpp>
#if defined(BOOST_MPL_CFG_NO_HAS_XXX)
# define HAS_XXX_ASSERT(x) MPL_ASSERT_NOT(x)
#endif
#if defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT_NOT(x)
#endif
#include "has_xxx.cpp"

View File

@@ -0,0 +1,155 @@
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/aux_/test.hpp>
struct complex_tag : int_<10> {};
template< typename Re, typename Im > struct complex
{
typedef complex_tag tag;
typedef complex type;
typedef Re real;
typedef Im imag;
};
template< typename C > struct real : C::real {};
template< typename C > struct imag : C::imag {};
namespace boost { namespace mpl {
template<> struct BOOST_MPL_AUX_NUMERIC_CAST< integral_c_tag,complex_tag >
{
template< typename N > struct apply
: complex< N, integral_c< typename N::value_type, 0 > >
{
};
};
template<>
struct plus_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: complex<
plus< typename N1::real, typename N2::real >
, plus< typename N1::imag, typename N2::imag >
>
{
};
};
template<>
struct times_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: complex<
minus<
times< typename N1::real, typename N2::real >
, times< typename N1::imag, typename N2::imag >
>
, plus<
times< typename N1::real, typename N2::imag >
, times< typename N1::imag, typename N2::real >
>
>
{
};
};
template<>
struct equal_to_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: and_<
equal_to< typename N1::real, typename N2::real >
, equal_to< typename N1::imag, typename N2::imag >
>
{
};
};
}}
typedef int_<2> i;
typedef complex< int_<5>, int_<-1> > c1;
typedef complex< int_<-5>, int_<1> > c2;
MPL_TEST_CASE()
{
typedef plus<c1,c2>::type r1;
MPL_ASSERT_RELATION( real<r1>::value, ==, 0 );
MPL_ASSERT_RELATION( imag<r1>::value, ==, 0 );
typedef plus<c1,c1>::type r2;
MPL_ASSERT_RELATION( real<r2>::value, ==, 10 );
MPL_ASSERT_RELATION( imag<r2>::value, ==, -2 );
typedef plus<c2,c2>::type r3;
MPL_ASSERT_RELATION( real<r3>::value, ==, -10 );
MPL_ASSERT_RELATION( imag<r3>::value, ==, 2 );
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
typedef plus<c1,i>::type r4;
MPL_ASSERT_RELATION( real<r4>::value, ==, 7 );
MPL_ASSERT_RELATION( imag<r4>::value, ==, -1 );
typedef plus<i,c2>::type r5;
MPL_ASSERT_RELATION( real<r5>::value, ==, -3 );
MPL_ASSERT_RELATION( imag<r5>::value, ==, 1 );
#endif
}
MPL_TEST_CASE()
{
typedef times<c1,c2>::type r1;
MPL_ASSERT_RELATION( real<r1>::value, ==, -24 );
MPL_ASSERT_RELATION( imag<r1>::value, ==, 10 );
typedef times<c1,c1>::type r2;
MPL_ASSERT_RELATION( real<r2>::value, ==, 24 );
MPL_ASSERT_RELATION( imag<r2>::value, ==, -10 );
typedef times<c2,c2>::type r3;
MPL_ASSERT_RELATION( real<r3>::value, ==, 24 );
MPL_ASSERT_RELATION( imag<r3>::value, ==, -10 );
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
typedef times<c1,i>::type r4;
MPL_ASSERT_RELATION( real<r4>::value, ==, 10 );
MPL_ASSERT_RELATION( imag<r4>::value, ==, -2 );
typedef times<i,c2>::type r5;
MPL_ASSERT_RELATION( real<r5>::value, ==, -10 );
MPL_ASSERT_RELATION( imag<r5>::value, ==, 2 );
#endif
}
MPL_TEST_CASE()
{
MPL_ASSERT(( equal_to<c1,c1> ));
MPL_ASSERT(( equal_to<c2,c2> ));
MPL_ASSERT_NOT(( equal_to<c1,c2> ));
MPL_ASSERT(( equal_to<c1, complex< long_<5>, long_<-1> > > ));
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
MPL_ASSERT_NOT(( equal_to<c1,i> ));
MPL_ASSERT_NOT(( equal_to<i,c2> ));
#endif
}

View File

@@ -0,0 +1,45 @@
// Copyright David Abrahams 2003-2004
// Copyright Aleksey Gurtovoy 2004
//
// 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$
// $Revision$
#include <boost/mpl/pair_view.hpp>
#include <boost/mpl/vector/vector50_c.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef range_c<int,0,10> r;
typedef vector10_c<int,9,8,7,6,5,4,3,2,1,10> v;
typedef pair_view<r,v> view;
typedef begin<view>::type first_;
typedef end<view>::type last_;
MPL_ASSERT(( is_same< first_::category, mpl::random_access_iterator_tag > ));
MPL_ASSERT(( is_same< advance_c<first_,0>::type, first_ > ));
MPL_ASSERT(( is_same< advance_c<last_,0>::type, last_ > ));
MPL_ASSERT(( is_same< advance_c<first_,10>::type, last_ > ));
MPL_ASSERT(( is_same< advance_c<last_,-10>::type, first_ > ));
typedef advance_c<first_,5>::type iter;
MPL_ASSERT(( is_same<
deref<iter>::type
, mpl::pair< integral_c<int,5>,integral_c<int,4> >
> ));
}

View File

@@ -0,0 +1,42 @@
// Copyright Aleksey Gurtovoy 2004
//
// 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$
// $Revision$
#include <boost/mpl/partition.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/back_inserter.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/modulus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename N > struct is_odd
: modulus< N, int_<2> >
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_odd, (N))
};
MPL_TEST_CASE()
{
typedef partition<
range_c<int,0,10>
, is_odd<_1>
, mpl::back_inserter< vector<> >
, mpl::back_inserter< vector<> >
>::type r;
MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > ));
MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > ));
}

View File

@@ -0,0 +1,36 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<long>::type types1;
typedef list<int,long>::type types2;
typedef list<char,int,long>::type types3;
typedef pop_front<types1>::type result1;
typedef pop_front<types2>::type result2;
typedef pop_front<types3>::type result3;
MPL_ASSERT_RELATION( size<result1>::value, ==, 0 );
MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
MPL_ASSERT_RELATION( size<result3>::value, ==, 2 );
MPL_ASSERT(( is_same< front<result2>::type, long > ));
MPL_ASSERT(( is_same< front<result3>::type, int > ));
}

22
libs/mpl/test/print.cpp Normal file
View File

@@ -0,0 +1,22 @@
// Copyright Aleksey Gurtovoy 2004
//
// 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$
// $Revision$
#include <boost/mpl/print.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef print<int>::type t;
}

View 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 > ));
}

View File

@@ -0,0 +1,50 @@
// 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
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#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;
typedef push_front<list1<long>,int>::type res2;
typedef push_front<list2<int,long>,char>::type res3;
MPL_ASSERT_RELATION( size<res1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<res2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<res3>::value, ==, 3 );
MPL_ASSERT(( is_same< front<res1>::type, long > ));
MPL_ASSERT(( is_same< front<res2>::type, int > ));
MPL_ASSERT(( is_same< front<res3>::type, char > ));
MPL_ASSERT(( has_push_front< list0<> > ));
MPL_ASSERT(( has_push_front< list1<long> > ));
MPL_ASSERT_NOT(( has_push_back< list0<> > ));
MPL_ASSERT_NOT(( has_push_front< no_push_front > ));
}

42
libs/mpl/test/quote.cpp Normal file
View File

@@ -0,0 +1,42 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/quote.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct f1
{
typedef T type;
};
template<
typename T1, typename T2, typename T3, typename T4, typename T5
>
struct f5
{
#if !defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS)
// no 'type' member!
#else
typedef f5 type;
#endif
};
MPL_TEST_CASE()
{
typedef quote1<f1>::apply<int>::type t1;
typedef quote5<f5>::apply<char,short,int,long,float>::type t5;
MPL_ASSERT(( boost::is_same< t1, int > ));
MPL_ASSERT(( boost::is_same< t5, f5<char,short,int,long,float> > ));
}

60
libs/mpl/test/range_c.cpp Normal file
View File

@@ -0,0 +1,60 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef range_c<int,0,0> range0;
typedef range_c<int,0,1> range1;
typedef range_c<int,0,10> range10;
MPL_ASSERT_RELATION( size<range0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<range1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<range10>::value, ==, 10 );
MPL_ASSERT(( empty<range0> ));
MPL_ASSERT_NOT(( empty<range1> ));
MPL_ASSERT_NOT(( empty<range10> ));
MPL_ASSERT(( is_same< begin<range0>::type, end<range0>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range10>::type, end<range10>::type > ));
MPL_ASSERT_RELATION( front<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<range10>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range10>::type::value, ==, 9 );
}
MPL_TEST_CASE()
{
typedef range_c<unsigned char,0,10> r;
typedef begin<r>::type first;
typedef end<r>::type last;
MPL_ASSERT(( is_same< advance_c<first,10>::type, last > ));
MPL_ASSERT(( is_same< advance_c<last,-10>::type, first > ));
MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 10 );
typedef advance_c<first,5>::type iter;
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}

28
libs/mpl/test/remove.cpp Normal file
View File

@@ -0,0 +1,28 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/remove.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector6<int,float,char,float,float,double> types;
typedef mpl::remove< types,float >::type result;
typedef vector3<int,char,double> answer;
MPL_ASSERT(( equal< result,answer > ));
}

View File

@@ -0,0 +1,54 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/remove_if.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list10_c<int,0,1,2,3,4,5,6,7,8,9> numbers;
typedef list5_c<int,4,3,2,1,0>::type answer;
typedef remove_if<
numbers
, greater<_,int_<4> >
, mpl::front_inserter< list0_c<int> >
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 5 );
MPL_ASSERT(( equal<result,answer> ));
}
MPL_TEST_CASE()
{
typedef list8<int,float,long,float,char,long,double,double> types;
typedef list4<int,long,char,long>::type answer;
typedef reverse_remove_if<
types
, is_float<_>
, mpl::front_inserter< list0<> >
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 4 );
MPL_ASSERT(( equal<result,answer> ));
}

27
libs/mpl/test/replace.cpp Normal file
View File

@@ -0,0 +1,27 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/replace.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,float,char,float,float,double> types;
typedef replace< types,float,double >::type result;
typedef list<int,double,char,double,double,double> answer;
MPL_ASSERT(( equal< result,answer > ));
}

View File

@@ -0,0 +1,33 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright John R. Bandela 2000-2002
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/replace_if.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list8_c<int,1,4,5,2,7,5,3,5>::type numbers;
typedef replace_if< numbers, greater<_1,int_<4> >, int_<0> >::type result;
typedef list8_c<int,1,4,0,2,0,0,3,0>::type answer;
MPL_ASSERT(( equal< answer,result,equal_to<_1,_2> > ));
}

32
libs/mpl/test/reverse.cpp Normal file
View File

@@ -0,0 +1,32 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/reverse.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
typedef reverse< numbers >::type result;
typedef range_c<int,0,10> answer;
MPL_ASSERT(( equal< result,answer,equal_to<_1,_2> > ));
}

23
libs/mpl/test/same_as.cpp Normal file
View File

@@ -0,0 +1,23 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/same_as.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( apply1< same_as<int>,int > ));
MPL_ASSERT_NOT(( apply1< same_as<int>,long > ));
}

347
libs/mpl/test/set.cpp Normal file
View File

@@ -0,0 +1,347 @@
// Copyright Aleksey Gurtovoy 2003-2007
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/set.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/has_key.hpp>
#include <boost/mpl/order.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
// Use templates for testing so that GCC will show us the actual types involved
template< typename s >
void empty_set_test()
{
MPL_ASSERT_RELATION( size<s>::value, ==, 0 );
MPL_ASSERT(( empty<s> ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, void_ > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > ));
MPL_ASSERT_NOT(( has_key<s,int> ));
MPL_ASSERT_NOT(( has_key<s,char> ));
MPL_ASSERT_NOT(( has_key<s,long> ));
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
MPL_ASSERT(( is_same< o1, void_ > ));
MPL_ASSERT(( is_same< o2, void_ > ));
MPL_ASSERT(( is_same< o3, void_ > ));
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
MPL_ASSERT(( is_same<first, last> ));
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 0 );
}
template< typename s >
void int_set_test()
{
MPL_ASSERT_RELATION( size<s>::value, ==, 1 );
MPL_ASSERT_NOT(( empty<s> ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > ));
MPL_ASSERT(( has_key<s,int> ));
MPL_ASSERT_NOT(( has_key<s,char> ));
MPL_ASSERT_NOT(( has_key<s,long> ));
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
MPL_ASSERT(( is_same< o2, void_ > ));
MPL_ASSERT(( is_same< o3, void_ > ));
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME deref<first>::type, int > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME next<first>::type, last > ));
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 1 );
MPL_ASSERT(( contains< s, int > ));
}
template< typename s >
void int_char_set_test()
{
MPL_ASSERT_RELATION( size<s>::value, ==, 2 );
MPL_ASSERT_NOT(( empty<s> ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > ));
MPL_ASSERT(( has_key<s,char> ));
MPL_ASSERT_NOT(( has_key<s,long> ));
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
MPL_ASSERT_NOT(( is_same< o2, void_ > ));
MPL_ASSERT(( is_same< o3, void_ > ));
MPL_ASSERT_NOT(( is_same< o1, o2 > ));
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 2 );
MPL_ASSERT(( contains< s, int > ));
MPL_ASSERT(( contains< s, char > ));
}
template< typename s >
void int_char_long_set_test()
{
MPL_ASSERT_RELATION( size<s>::value, ==, 3 );
MPL_ASSERT_NOT(( empty<s> ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, long > ));
MPL_ASSERT(( has_key<s,long> ));
MPL_ASSERT(( has_key<s,int> ));
MPL_ASSERT(( has_key<s,char> ));
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
MPL_ASSERT_NOT(( is_same< o2, void_ > ));
MPL_ASSERT_NOT(( is_same< o3, void_ > ));
MPL_ASSERT_NOT(( is_same< o1, o2 > ));
MPL_ASSERT_NOT(( is_same< o1, o3 > ));
MPL_ASSERT_NOT(( is_same< o2, o3 > ));
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 3 );
MPL_ASSERT(( contains< s, int > ));
MPL_ASSERT(( contains< s, char > ));
MPL_ASSERT(( contains< s, long > ));
}
template< typename S0, typename S1, typename S2, typename S3 >
void basic_set_test()
{
empty_set_test<S0>();
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<S1,int>::type >();
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<
BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type
, int
>::type >();
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<
BOOST_DEDUCED_TYPENAME erase_key<
BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type
, long
>::type
, int
>::type >();
int_set_test<S1>();
int_set_test< BOOST_DEDUCED_TYPENAME insert<S0,int>::type >();
int_set_test< BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type >();
int_set_test< BOOST_DEDUCED_TYPENAME erase_key<
BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type
, long
>::type >();
int_char_set_test<S2>();
int_char_set_test< BOOST_DEDUCED_TYPENAME insert<
BOOST_DEDUCED_TYPENAME insert<S0,char>::type
, int
>::type >();
int_char_set_test< BOOST_DEDUCED_TYPENAME insert<S1,char>::type >();
int_char_set_test< BOOST_DEDUCED_TYPENAME erase_key<S3,long>::type >();
int_char_long_set_test<S3>();
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<
BOOST_DEDUCED_TYPENAME insert<
BOOST_DEDUCED_TYPENAME insert<S0,char>::type
, long
>::type
, int
>::type >();
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<
BOOST_DEDUCED_TYPENAME insert<S1,long>::type
, char
>::type >();
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<S2,long>::type >();
}
template< typename S1, typename S2 >
void numbered_vs_variadic_set_test()
{
MPL_ASSERT(( is_same< S1, BOOST_DEDUCED_TYPENAME S1::type > ));
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME S2::type, S1 > ));
}
MPL_TEST_CASE()
{
typedef mpl::set0<> s01;
typedef mpl::set<> s02;
typedef mpl::set1<int> s11;
typedef mpl::set<int> s12;
typedef mpl::set2<int,char> s21;
typedef mpl::set<int,char> s22;
typedef mpl::set<char,int> s23;
typedef mpl::set3<int,char,long> s31;
typedef mpl::set<int,char,long> s32;
typedef mpl::set<int,long,char> s33;
typedef mpl::set<long,char,int> s34;
numbered_vs_variadic_set_test<s01,s02>();
numbered_vs_variadic_set_test<s11,s12>();
numbered_vs_variadic_set_test<s21,s22>();
numbered_vs_variadic_set_test<s31,s32>();
basic_set_test<s01,s11,s21,s31>();
basic_set_test<s02,s12,s22,s32>();
basic_set_test<s01,s11,s23,s31>();
basic_set_test<s01,s11,s23,s33>();
basic_set_test<s01,s11,s23,s34>();
}
template< typename s >
void empty_set_types_variety_test()
{
MPL_ASSERT_NOT(( has_key<s,char> ));
MPL_ASSERT_NOT(( has_key<s,int> ));
MPL_ASSERT_NOT(( has_key<s,UDT> ));
MPL_ASSERT_NOT(( has_key<s,incomplete> ));
MPL_ASSERT_NOT(( has_key<s,char const> ));
MPL_ASSERT_NOT(( has_key<s,int const> ));
MPL_ASSERT_NOT(( has_key<s,UDT const> ));
MPL_ASSERT_NOT(( has_key<s,incomplete const> ));
MPL_ASSERT_NOT(( has_key<s,int*> ));
MPL_ASSERT_NOT(( has_key<s,UDT*> ));
MPL_ASSERT_NOT(( has_key<s,incomplete*> ));
MPL_ASSERT_NOT(( has_key<s,int&> ));
MPL_ASSERT_NOT(( has_key<s,UDT&> ));
MPL_ASSERT_NOT(( has_key<s,incomplete&> ));
}
template< typename s >
void set_types_variety_test()
{
MPL_ASSERT_RELATION( size<s>::value, ==, 8 );
MPL_ASSERT(( has_key<s,char> ));
MPL_ASSERT(( has_key<s,int const> ));
MPL_ASSERT(( has_key<s,long*> ));
MPL_ASSERT(( has_key<s,UDT* const> ));
MPL_ASSERT(( has_key<s,incomplete> ));
MPL_ASSERT(( has_key<s,abstract> ));
MPL_ASSERT(( has_key<s,incomplete volatile&> ));
MPL_ASSERT(( has_key<s,abstract const&> ));
MPL_ASSERT_NOT(( has_key<s,char const> ));
MPL_ASSERT_NOT(( has_key<s,int> ));
MPL_ASSERT_NOT(( has_key<s,long* const> ));
MPL_ASSERT_NOT(( has_key<s,UDT*> ));
MPL_ASSERT_NOT(( has_key<s,incomplete const> ));
MPL_ASSERT_NOT(( has_key<s,abstract volatile> ));
MPL_ASSERT_NOT(( has_key<s,incomplete&> ));
MPL_ASSERT_NOT(( has_key<s,abstract&> ));
}
MPL_TEST_CASE()
{
empty_set_types_variety_test< set<> >();
empty_set_types_variety_test< set<>::type >();
typedef set<
char,int const,long*,UDT* const,incomplete,abstract
, incomplete volatile&,abstract const&
> s;
set_types_variety_test<s>();
set_types_variety_test<s::type>();
}
template <class S>
void find_test()
{
MPL_ASSERT_RELATION( size<S>::value, ==, 3 );
typedef typename end<S>::type not_found;
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,int>::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,long>::type,not_found> ));
BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char>::type,not_found> ));
BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char*>::type,not_found> ));
}
MPL_TEST_CASE()
{
typedef mpl::set<int,long,char> s;
find_test<s>();
find_test<s::type>();
}
MPL_TEST_CASE()
{
typedef insert< set<>, int >::type little_set;
MPL_ASSERT_RELATION(size<little_set>::value, ==, 1);
MPL_ASSERT_RELATION(size<little_set::type>::value, ==, 1);
}
MPL_TEST_CASE()
{
typedef erase_key< set< float, int >, float >::type little_set;
MPL_ASSERT_RELATION(size<little_set>::value, ==, 1);
MPL_ASSERT_RELATION(size<little_set::type>::value, ==, 1);
}

106
libs/mpl/test/set_c.cpp Normal file
View File

@@ -0,0 +1,106 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/set_c.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
namespace test { namespace {
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
template< typename S, typename S::value_type k >
struct at_c
: at< S, integral_c<typename S::value_type,k> >::type
{
};
#else
template< typename S, long k >
struct at_c
: aux::msvc_eti_base<
at< S, integral_c<typename S::value_type,k> >
>
{
};
#endif
}}
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
MPL_TEST_CASE()
{
typedef set_c<bool,true>::type s1;
typedef set_c<bool,false>::type s2;
typedef set_c<bool,true,false>::type s3;
MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<s2>::value, ==, 1 );
MPL_ASSERT_RELATION( size<s3>::value, ==, 2 );
MPL_ASSERT(( is_same< s1::value_type, bool > ));
MPL_ASSERT(( is_same< s3::value_type, bool > ));
MPL_ASSERT(( is_same< s2::value_type, bool > ));
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
MPL_ASSERT_RELATION( ( test::at_c<s1,true>::value ), ==, true );
MPL_ASSERT_RELATION( ( test::at_c<s2,false>::value ), ==, false );
MPL_ASSERT_RELATION( ( test::at_c<s3,true>::value ), ==, true );
MPL_ASSERT_RELATION( ( test::at_c<s3,false>::value ), ==, false );
MPL_ASSERT(( is_same< test::at_c<s1,false>::type, void_ > ));
MPL_ASSERT(( is_same< test::at_c<s2,true>::type, void_ > ));
#endif
typedef begin<s1>::type first1;
typedef end<s1>::type last1;
MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 );
typedef begin<s2>::type first2;
typedef end<s2>::type last2;
MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 1 );
typedef begin<s3>::type first3;
typedef end<s3>::type last3;
MPL_ASSERT_RELATION( (distance<first3, last3>::value), ==, 2 );
}
#endif
MPL_TEST_CASE()
{
typedef set_c<char,'a'>::type s1;
typedef set_c<char,'a','b','c','d','e','f','g','h'>::type s2;
MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<s2>::value, ==, 8 );
MPL_ASSERT(( is_same< s1::value_type, char > ));
MPL_ASSERT(( is_same< s2::value_type, char > ));
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
MPL_ASSERT_RELATION( ( test::at_c<s1,'a'>::value ), ==, 'a' );
MPL_ASSERT_RELATION( ( test::at_c<s2,'a'>::value ), ==, 'a' );
MPL_ASSERT_RELATION( ( test::at_c<s2,'d'>::value ), ==, 'd' );
MPL_ASSERT_RELATION( ( test::at_c<s2,'h'>::value ), ==, 'h' );
MPL_ASSERT(( is_same< test::at_c<s1,'z'>::type, void_ > ));
MPL_ASSERT(( is_same< test::at_c<s2,'k'>::type, void_ > ));
#endif
typedef begin<s1>::type first1;
typedef end<s1>::type last1;
MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 );
typedef begin<s2>::type first2;
typedef end<s2>::type last2;
MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 8 );
}

View File

@@ -0,0 +1,43 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/single_view.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef single_view<int> view;
typedef begin<view>::type first;
typedef end<view>::type last;
MPL_ASSERT(( is_same< deref<first>::type, int > ));
MPL_ASSERT(( is_same< next<first>::type, last > ));
MPL_ASSERT(( is_same< prior<last>::type, first > ));
MPL_ASSERT(( is_same< mpl::advance<first, int_<0> >::type, first > ));
MPL_ASSERT(( is_same< mpl::advance<first, int_<1> >::type, last > ));
MPL_ASSERT(( is_same< mpl::advance<last, int_<0> >::type, last > ));
MPL_ASSERT(( is_same< mpl::advance<last, int_<-1> >::type, first > ));
MPL_ASSERT_RELATION( (mpl::distance<first,first>::value), ==, 0 );
MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 1 );
MPL_ASSERT_RELATION( (mpl::distance<last,last>::value), ==, 0 );
MPL_ASSERT_RELATION( size<view>::value, ==, 1 );
MPL_ASSERT(( equal< view, view::type > ));
}

26
libs/mpl/test/size.cpp Normal file
View File

@@ -0,0 +1,26 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/size.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<> empty_list;
typedef list<char,short,int,long> list;
MPL_ASSERT_RELATION( size<empty_list>::value, ==, 0 );
MPL_ASSERT_RELATION( size<list>::value, ==, 4 );
}

29
libs/mpl/test/size_t.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
// Necessary to overcome a strange name lookup bug in GCC 3.3 and 4.0 for Mac OS X
#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ <= 4)
# include <cassert>
#endif
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include "integral_wrapper_test.hpp"
MPL_TEST_CASE()
{
# define WRAPPER(T, i) mpl::size_t<i>
BOOST_PP_REPEAT_FROM_TO(1, 11, INTEGRAL_WRAPPER_TEST, std::size_t)
}

28
libs/mpl/test/sizeof.cpp Normal file
View File

@@ -0,0 +1,28 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/aux_/test.hpp>
struct my
{
char a[100];
};
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( sizeof_<char>::value, ==, sizeof(char) );
MPL_ASSERT_RELATION( sizeof_<int>::value, ==, sizeof(int) );
MPL_ASSERT_RELATION( sizeof_<double>::value, ==, sizeof(double) );
MPL_ASSERT_RELATION( sizeof_<my>::value, ==, sizeof(my) );
}

27
libs/mpl/test/sort.cpp Normal file
View File

@@ -0,0 +1,27 @@
// Copyright Aleksey Gurtovoy 2004
// Copyright Eric Friedman 2002-2003
//
// 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.
#include <boost/mpl/sort.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list_c<int, 3, 4, 0, -5, 8, -1, 7>::type numbers;
typedef list_c<int, -5, -1, 0, 3, 4, 7, 8>::type manual_result;
typedef sort< numbers >::type result;
MPL_ASSERT(( equal< result,manual_result,equal_to<_1,_2> > ));
}

View File

@@ -0,0 +1,47 @@
// Copyright Aleksey Gurtovoy 2004
// Copyright Eric Friedman 2003
//
// 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$
// $Revision$
#include <boost/mpl/stable_partition.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
typedef vector_c<int,3,4,0,-5,8,-1,7>::type numbers;
typedef vector_c<int,0,-5,-1>::type manual_first;
typedef vector_c<int,3,4,8,7>::type manual_second;
MPL_TEST_CASE()
{
typedef stable_partition<
numbers
, less< _, int_<3> >
>::type result;
MPL_ASSERT(( equal< result::first,manual_first > ));
MPL_ASSERT(( equal< result::second,manual_second > ));
}
MPL_TEST_CASE()
{
typedef stable_partition<
numbers
, greater_equal< _, int_<3> >
>::type result;
MPL_ASSERT(( equal< result::first,manual_second > ));
MPL_ASSERT(( equal< result::second,manual_first > ));
}

516
libs/mpl/test/string.cpp Normal file
View File

@@ -0,0 +1,516 @@
// Copyright Eric Niebler 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: string.cpp 49240 2009-04-01 09:21:07Z eric_niebler $
// $Date: 2009-04-01 02:21:07 -0700 (Wed, 1 Apr 2009) $
// $Revision: 49240 $
#include <string>
#include <cstring>
#include <iostream>
#include <boost/mpl/string.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/pop_back.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
namespace mpl = boost::mpl;
// Accept a string as a template parameter!
template<char const *sz>
struct greeting
{
std::string say_hello() const
{
return sz;
}
};
struct push_char
{
push_char(std::string &str)
: str_(&str)
{}
void operator()(char ch) const
{
this->str_->push_back(ch);
}
std::string *str_;
};
int main()
{
// Test mpl::size of strings
{
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full;
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> full;
BOOST_MPL_ASSERT_RELATION(0, ==, (mpl::size<mpl::string<> >::value));
BOOST_MPL_ASSERT_RELATION(1, ==, (mpl::size<mpl::string<'a'> >::value));
BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size<mpl::string<'ab'> >::value));
BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size<mpl::string<'a','b'> >::value));
BOOST_MPL_ASSERT_RELATION(4, ==, (mpl::size<mpl::string<'abcd'> >::value));
BOOST_MPL_ASSERT_RELATION(5, ==, (mpl::size<mpl::string<'abcd','e'> >::value));
BOOST_MPL_ASSERT_RELATION(31, ==, (mpl::size<almost_full>::value));
BOOST_MPL_ASSERT_RELATION(32, ==, (mpl::size<full>::value));
}
// Test mpl::begin and mpl::end with strings
{
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full;
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> full;
BOOST_MPL_ASSERT((
boost::is_same<
mpl::begin<mpl::string<> >::type
, mpl::end<mpl::string<> >::type
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::begin<mpl::string<'a'> >::type
, mpl::string_iterator<mpl::string<'a'>, 0, 0>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::end<mpl::string<'a'> >::type
, mpl::string_iterator<mpl::string<'a'>, 1, 0>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::begin<almost_full>::type
, mpl::string_iterator<almost_full, 0, 0>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::end<almost_full>::type
, mpl::string_iterator<almost_full, 8, 0>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::begin<full>::type
, mpl::string_iterator<full, 0, 0>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::end<full>::type
, mpl::string_iterator<full, 8, 0>
>
));
}
// testing push_back
{
typedef mpl::push_back<mpl::string<>, mpl::char_<'a'> >::type t1;
BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >));
typedef mpl::push_back<t1, mpl::char_<'b'> >::type t2;
BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ab'> >));
typedef mpl::push_back<t2, mpl::char_<'c'> >::type t3;
BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'abc'> >));
typedef mpl::push_back<t3, mpl::char_<'d'> >::type t4;
BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'abcd'> >));
typedef mpl::push_back<t4, mpl::char_<'e'> >::type t5;
BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'abcd','e'> >));
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full;
typedef mpl::push_back<almost_full, mpl::char_<'X'> >::type t6;
BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >));
}
// Test mpl::next
{
typedef mpl::string<'a','bc','def','ghij'> s;
typedef mpl::begin<s>::type i0;
BOOST_MPL_ASSERT((boost::is_same<i0, mpl::string_iterator<s,0,0> >));
typedef mpl::next<i0>::type i1;
BOOST_MPL_ASSERT((boost::is_same<i1, mpl::string_iterator<s,1,0> >));
typedef mpl::next<i1>::type i2;
BOOST_MPL_ASSERT((boost::is_same<i2, mpl::string_iterator<s,1,1> >));
typedef mpl::next<i2>::type i3;
BOOST_MPL_ASSERT((boost::is_same<i3, mpl::string_iterator<s,2,0> >));
typedef mpl::next<i3>::type i4;
BOOST_MPL_ASSERT((boost::is_same<i4, mpl::string_iterator<s,2,1> >));
typedef mpl::next<i4>::type i5;
BOOST_MPL_ASSERT((boost::is_same<i5, mpl::string_iterator<s,2,2> >));
typedef mpl::next<i5>::type i6;
BOOST_MPL_ASSERT((boost::is_same<i6, mpl::string_iterator<s,3,0> >));
typedef mpl::next<i6>::type i7;
BOOST_MPL_ASSERT((boost::is_same<i7, mpl::string_iterator<s,3,1> >));
typedef mpl::next<i7>::type i8;
BOOST_MPL_ASSERT((boost::is_same<i8, mpl::string_iterator<s,3,2> >));
typedef mpl::next<i8>::type i9;
BOOST_MPL_ASSERT((boost::is_same<i9, mpl::string_iterator<s,3,3> >));
typedef mpl::next<i9>::type i10;
BOOST_MPL_ASSERT((boost::is_same<i10, mpl::string_iterator<s,4,0> >));
BOOST_MPL_ASSERT((boost::is_same<i10, mpl::end<s>::type>));
}
// Test mpl::prior
{
typedef mpl::string<'a','bc','def','ghij'> s;
typedef mpl::end<s>::type i10;
BOOST_MPL_ASSERT((boost::is_same<i10, mpl::string_iterator<s,4,0> >));
typedef mpl::prior<i10>::type i9;
BOOST_MPL_ASSERT((boost::is_same<i9, mpl::string_iterator<s,3,3> >));
typedef mpl::prior<i9>::type i8;
BOOST_MPL_ASSERT((boost::is_same<i8, mpl::string_iterator<s,3,2> >));
typedef mpl::prior<i8>::type i7;
BOOST_MPL_ASSERT((boost::is_same<i7, mpl::string_iterator<s,3,1> >));
typedef mpl::prior<i7>::type i6;
BOOST_MPL_ASSERT((boost::is_same<i6, mpl::string_iterator<s,3,0> >));
typedef mpl::prior<i6>::type i5;
BOOST_MPL_ASSERT((boost::is_same<i5, mpl::string_iterator<s,2,2> >));
typedef mpl::prior<i5>::type i4;
BOOST_MPL_ASSERT((boost::is_same<i4, mpl::string_iterator<s,2,1> >));
typedef mpl::prior<i4>::type i3;
BOOST_MPL_ASSERT((boost::is_same<i3, mpl::string_iterator<s,2,0> >));
typedef mpl::prior<i3>::type i2;
BOOST_MPL_ASSERT((boost::is_same<i2, mpl::string_iterator<s,1,1> >));
typedef mpl::prior<i2>::type i1;
BOOST_MPL_ASSERT((boost::is_same<i1, mpl::string_iterator<s,1,0> >));
typedef mpl::prior<i1>::type i0;
BOOST_MPL_ASSERT((boost::is_same<i0, mpl::string_iterator<s,0,0> >));
BOOST_MPL_ASSERT((boost::is_same<i0, mpl::begin<s>::type>));
}
// Test mpl::deref
{
typedef mpl::string<'a','bc','def','ghij'> s;
typedef mpl::begin<s>::type i0;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i0>::type, mpl::char_<'a'> >));
typedef mpl::next<i0>::type i1;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i1>::type, mpl::char_<'b'> >));
typedef mpl::next<i1>::type i2;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i2>::type, mpl::char_<'c'> >));
typedef mpl::next<i2>::type i3;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i3>::type, mpl::char_<'d'> >));
typedef mpl::next<i3>::type i4;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i4>::type, mpl::char_<'e'> >));
typedef mpl::next<i4>::type i5;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i5>::type, mpl::char_<'f'> >));
typedef mpl::next<i5>::type i6;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i6>::type, mpl::char_<'g'> >));
typedef mpl::next<i6>::type i7;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i7>::type, mpl::char_<'h'> >));
typedef mpl::next<i7>::type i8;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i8>::type, mpl::char_<'i'> >));
typedef mpl::next<i8>::type i9;
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i9>::type, mpl::char_<'j'> >));
}
// testing push_back
{
typedef mpl::push_back<mpl::string<>, mpl::char_<'a'> >::type t1;
BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >));
typedef mpl::push_back<t1, mpl::char_<'b'> >::type t2;
BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ab'> >));
typedef mpl::push_back<t2, mpl::char_<'c'> >::type t3;
BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'abc'> >));
typedef mpl::push_back<t3, mpl::char_<'d'> >::type t4;
BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'abcd'> >));
typedef mpl::push_back<t4, mpl::char_<'e'> >::type t5;
BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'abcd','e'> >));
typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full;
typedef mpl::push_back<almost_full, mpl::char_<'X'> >::type t6;
BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >));
typedef mpl::string<'a','a','a','a','a','a','a','aaaa'> must_repack;
typedef mpl::push_back<must_repack, mpl::char_<'X'> >::type t7;
BOOST_MPL_ASSERT((boost::is_same<t7, mpl::string<'aaaa','aaaa','aaaX'> >));
}
BOOST_MPL_ASSERT((mpl::empty<mpl::string<> >));
BOOST_MPL_ASSERT_NOT((mpl::empty<mpl::string<'hi!'> >));
// testing push_front
{
typedef mpl::push_front<mpl::string<>, mpl::char_<'a'> >::type t1;
BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >));
typedef mpl::push_front<t1, mpl::char_<'b'> >::type t2;
BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ba'> >));
typedef mpl::push_front<t2, mpl::char_<'c'> >::type t3;
BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'cba'> >));
typedef mpl::push_front<t3, mpl::char_<'d'> >::type t4;
BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'dcba'> >));
typedef mpl::push_front<t4, mpl::char_<'e'> >::type t5;
BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'e','dcba'> >));
typedef mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> almost_full;
typedef mpl::push_front<almost_full, mpl::char_<'X'> >::type t6;
BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'Xaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >));
typedef mpl::string<'aaaa','a','a','a','a','a','a','a'> must_repack;
typedef mpl::push_front<must_repack, mpl::char_<'X'> >::type t7;
BOOST_MPL_ASSERT((boost::is_same<t7, mpl::string<'Xaaa','aaaa','aaaa'> >));
}
// Test c_str<>
BOOST_TEST(0 == std::strcmp(
mpl::c_str<mpl::string<> >::value
, ""
));
BOOST_TEST(0 == std::strcmp(
mpl::c_str<mpl::string<'Hell','o wo','rld!'> >::value
, "Hell" "o wo" "rld!"
));
BOOST_TEST(0 == std::strcmp(
mpl::c_str<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >::value
, "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaX"
));
// test using a string as a template parameter
greeting<mpl::c_str<mpl::string<'Hell','o wo','rld!'> >::value> g;
BOOST_TEST("Hello world!" == g.say_hello());
std::string result;
mpl::for_each<mpl::string<'Hell','o wo','rld!'> >(push_char(result));
BOOST_TEST("Hello world!" == result);
BOOST_TEST(('h' == mpl::front<mpl::string<'hi!'> >::type()));
BOOST_TEST(('!' == mpl::back<mpl::string<'hi!'> >::type()));
// back-inserter with copy
typedef mpl::vector_c<char, 'a','b','c','d','e'> rgc;
BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str<rgc>::value));
typedef mpl::copy<rgc, mpl::back_inserter<mpl::string<> > >::type str;
BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str<str>::value));
// test insert_range and erase
{
typedef mpl::string<'Hell','o wo','rld!'> hello;
typedef mpl::advance_c<mpl::begin<hello>::type, 5>::type where;
typedef mpl::string<' cru','el'> cruel;
typedef mpl::insert_range<hello, where, cruel>::type hello_cruel;
BOOST_TEST(0 == std::strcmp("Hello cruel world!", mpl::c_str<hello_cruel>::value));
typedef mpl::erase<hello, mpl::begin<hello>::type, where>::type erased1;
BOOST_TEST(0 == std::strcmp(" world!", mpl::c_str<erased1>::value));
}
// test pop_front
{
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'a'> >::type
, mpl::string<>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'ab'> >::type
, mpl::string<'b'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'abc'> >::type
, mpl::string<'bc'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'abcd'> >::type
, mpl::string<'bcd'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'abcd','e'> >::type
, mpl::string<'bcd','e'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'d','e'> >::type
, mpl::string<'e'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_front<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >::type
, mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'>
>
));
}
// test pop_back
{
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'a'> >::type
, mpl::string<>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'ab'> >::type
, mpl::string<'a'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'abc'> >::type
, mpl::string<'ab'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'abcd'> >::type
, mpl::string<'abc'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'abcd','e'> >::type
, mpl::string<'abcd'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'d','e'> >::type
, mpl::string<'d'>
>
));
BOOST_MPL_ASSERT((
boost::is_same<
mpl::pop_back<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >::type
, mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'>
>
));
}
{
BOOST_TEST((
mpl::at_c<
mpl::string<'\x7f'>
, 0
>::type::value == (char)0x7f
));
BOOST_TEST((
mpl::at_c<
mpl::string<'\x80'>
, 0
>::type::value == (char)0x80
));
BOOST_TEST((
mpl::at_c<
mpl::string<
mpl::at_c<
mpl::string<'\x7f'>
, 0
>::type::value
>
, 0
>::type::value == (char)0x7f
));
BOOST_TEST((
mpl::at_c<
mpl::string<
mpl::at_c<
mpl::string<'\x80'>
, 0
>::type::value
>
, 0
>::type::value == (char)0x80
));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,51 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/transform.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/gcc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <boost/type_traits/add_pointer.hpp>
MPL_TEST_CASE()
{
typedef list<char,short,int,long,float,double> types;
typedef list<char*,short*,int*,long*,float*,double*> pointers;
typedef transform1< types,add_pointer<_1> >::type result;
MPL_ASSERT(( equal<result,pointers> ));
}
MPL_TEST_CASE()
{
typedef list_c<long,0,2,4,6,8,10> evens;
typedef list_c<long,2,3,5,7,11,13> primes;
typedef list_c<long,2,5,9,13,19,23> sums;
typedef transform2< evens, primes, plus<> >::type result;
MPL_ASSERT(( equal< result,sums,equal_to<_1,_2> > ));
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
typedef transform< evens, primes, plus<> >::type result2;
MPL_ASSERT(( is_same<result2,result> ));
#endif
}

View File

@@ -0,0 +1,40 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,long,char,char[50],double> types;
typedef list<
sizeof_<int>::type,
sizeof_<long>::type,
sizeof_<char>::type,
sizeof_<char[50]>::type,
sizeof_<double>::type
> sizes;
MPL_ASSERT(( equal< transform_view< types, sizeof_<_> >::type,sizes > ));
typedef max_element<
transform_view< types, sizeof_<_> >
>::type iter;
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 50 );
}

29
libs/mpl/test/unique.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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$
// $Revision$
#include <boost/mpl/unique.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list<int,float,float,char,int,int,int,double> types;
typedef unique< types, is_same<_1,_2> >::type result;
typedef list<int,float,char,int,double>::type answer;
MPL_ASSERT(( equal< result,answer > ));
}

View File

@@ -0,0 +1,26 @@
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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$
// $Revision$
#include <boost/mpl/unpack_args.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( apply1<
unpack_args< is_same<_1,_2> >
, vector2<int,int>
> ));
}

View File

@@ -0,0 +1,29 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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$
// $Revision$
#include <boost/mpl/upper_bound.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list_c<int,1,2,3,3,3,5,8> numbers;
typedef upper_bound< numbers, int_<3> >::type iter;
MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 );
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}

124
libs/mpl/test/vector.cpp Normal file
View File

@@ -0,0 +1,124 @@
// Copyright Aleksey Gurtovoy 2000-2005
//
// 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$
// $Revision$
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/pop_back.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector0<> v0;
typedef vector1<char> v1;
typedef vector2<char,long> v2;
typedef vector9<char,char,char,char,char,char,char,char,int> v9;
MPL_ASSERT(( equal< v0,v0::type > ));
MPL_ASSERT(( equal< v1,v1::type > ));
MPL_ASSERT(( equal< v2,v2::type > ));
MPL_ASSERT(( equal< v9,v9::type > ));
MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );
MPL_ASSERT(( empty<v0> ));
MPL_ASSERT_NOT(( empty<v1> ));
MPL_ASSERT_NOT(( empty<v2> ));
MPL_ASSERT_NOT(( empty<v9> ));
MPL_ASSERT(( is_same< front<v1>::type,char > ));
MPL_ASSERT(( is_same< back<v1>::type,char > ));
MPL_ASSERT(( is_same< front<v2>::type,char > ));
MPL_ASSERT(( is_same< back<v2>::type,long > ));
MPL_ASSERT(( is_same< front<v9>::type,char > ));
MPL_ASSERT(( is_same< back<v9>::type,int > ));
}
MPL_TEST_CASE()
{
typedef vector2<char,long> v2;
typedef begin<v2>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
MPL_ASSERT(( is_same<deref<i1>::type,char> ));
MPL_ASSERT(( is_same<deref<i2>::type,long> ));
MPL_ASSERT(( is_same< i3, end<v2>::type > ));
}
MPL_TEST_CASE()
{
typedef vector0<> v0;
typedef push_back<v0,int>::type v1;
typedef push_front<v1,char>::type v2;
typedef push_back<v2,long>::type v3;
MPL_ASSERT(( is_same< back<v1>::type,int > ));
MPL_ASSERT(( is_same< back<v2>::type,int > ));
MPL_ASSERT(( is_same< front<v2>::type,char > ));
MPL_ASSERT(( is_same< back<v3>::type,long > ));
MPL_ASSERT(( equal< v1,v1::type > ));
MPL_ASSERT(( equal< v2,v2::type > ));
MPL_ASSERT(( equal< v3,v3::type > ));
}
MPL_TEST_CASE()
{
typedef vector9<char,bool,char,char,char,char,bool,long,int> v9;
typedef pop_back<v9>::type v8;
typedef pop_front<v8>::type v7;
MPL_ASSERT(( is_same< back<v9>::type,int > ));
MPL_ASSERT(( is_same< back<v8>::type,long > ));
MPL_ASSERT(( is_same< back<v7>::type,long > ));
MPL_ASSERT(( is_same< front<v7>::type,bool > ));
MPL_ASSERT(( equal< v9,v9::type > ));
MPL_ASSERT(( equal< v8,v8::type > ));
MPL_ASSERT(( equal< v7,v7::type > ));
}
MPL_TEST_CASE()
{
typedef vector<> v0;
typedef vector<char> v1;
typedef vector<char,long> v2;
typedef vector<char,char,char,char,char,char,char,char,int> v9;
MPL_ASSERT(( equal< v0,v0::type > ));
MPL_ASSERT(( equal< v1,v1::type > ));
MPL_ASSERT(( equal< v2,v2::type > ));
MPL_ASSERT(( equal< v9,v9::type > ));
MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );
}

View File

@@ -0,0 +1,66 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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$
// $Revision$
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
#if !BOOST_WORKAROUND(BOOST_MSVC, <=1200)
MPL_TEST_CASE()
{
typedef vector_c<bool,true>::type v1;
typedef vector_c<bool,false>::type v2;
MPL_ASSERT(( is_same< v1::value_type, bool > ));
MPL_ASSERT(( is_same< v2::value_type, bool > ));
MPL_ASSERT_RELATION( front<v1>::type::value, ==, true );
MPL_ASSERT_RELATION( front<v2>::type::value, ==, false );
}
#endif
MPL_TEST_CASE()
{
typedef vector_c<int,-1> v1;
typedef vector_c<int,0,1> v2;
typedef vector_c<int,1,2,3> v3;
MPL_ASSERT(( is_same< v1::value_type, int > ));
MPL_ASSERT(( is_same< v2::value_type, int > ));
MPL_ASSERT(( is_same< v3::value_type, int > ));
MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<v3>::value, ==, 3 );
MPL_ASSERT_RELATION( front<v1>::type::value, ==, -1 );
MPL_ASSERT_RELATION( front<v2>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<v3>::type::value, ==, 1 );
}
MPL_TEST_CASE()
{
typedef vector_c<unsigned,0> v1;
typedef vector_c<unsigned,1,2> v2;
MPL_ASSERT(( is_same< v1::value_type, unsigned > ));
MPL_ASSERT(( is_same< v2::value_type, unsigned > ));
MPL_ASSERT_RELATION( size<v1>::type::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::type::value, ==, 2 );
MPL_ASSERT_RELATION( front<v1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<v2>::type::value, ==, 1 );
}

View File

@@ -0,0 +1,45 @@
// Copyright Aleksey Gurtovoy 2002-2010
//
// 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$
// $Revision$
#include <boost/mpl/zip_view.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/filter_view.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/unpack_args.hpp>
#include <boost/mpl/math/is_even.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
typedef transform_view<
zip_view< vector< range_c<int,0,10>, range_c<int,10,20> > >
, unpack_args< plus<> >
> result;
MPL_ASSERT(( equal<
result
, filter_view< range_c<int,10,30>, is_even<_> >
, equal_to<_,_>
> ));
MPL_ASSERT(( boost::is_same< zip_view<vector<> >, zip_view<vector<> >::type > ));
}