From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/mpl/test/Jamfile.v2 | 98 ++++ src/boost/libs/mpl/test/advance.cpp | 51 ++ src/boost/libs/mpl/test/always.cpp | 48 ++ src/boost/libs/mpl/test/apply.cpp | 128 +++++ src/boost/libs/mpl/test/apply_wrap.cpp | 121 +++++ src/boost/libs/mpl/test/arithmetic.cpp | 50 ++ src/boost/libs/mpl/test/as_sequence.cpp | 23 + src/boost/libs/mpl/test/assert.cpp | 101 ++++ src/boost/libs/mpl/test/assert_vc8.hpp | 28 ++ src/boost/libs/mpl/test/assert_vc8_p1.cpp | 23 + src/boost/libs/mpl/test/assert_vc8_p2.cpp | 19 + src/boost/libs/mpl/test/at.cpp | 39 ++ src/boost/libs/mpl/test/aux_/increased_arity.cpp | 50 ++ src/boost/libs/mpl/test/aux_/largest_int.cpp | 25 + src/boost/libs/mpl/test/aux_/msvc_is_class.cpp | 46 ++ .../libs/mpl/test/aux_/preprocessor/is_seq.cpp | 33 ++ .../mpl/test/aux_/preprocessor/token_equal.cpp | 36 ++ src/boost/libs/mpl/test/aux_/template_arity.cpp | 31 ++ src/boost/libs/mpl/test/back.cpp | 29 ++ src/boost/libs/mpl/test/bind.cpp | 89 ++++ src/boost/libs/mpl/test/bitwise.cpp | 71 +++ src/boost/libs/mpl/test/bool.cpp | 38 ++ src/boost/libs/mpl/test/char.cpp | 24 + src/boost/libs/mpl/test/comparison.cpp | 64 +++ src/boost/libs/mpl/test/contains.cpp | 24 + src/boost/libs/mpl/test/copy.cpp | 211 +++++++++ src/boost/libs/mpl/test/copy_if.cpp | 54 +++ src/boost/libs/mpl/test/count.cpp | 41 ++ src/boost/libs/mpl/test/count_if.cpp | 36 ++ src/boost/libs/mpl/test/deque.cpp | 92 ++++ src/boost/libs/mpl/test/distance.cpp | 37 ++ src/boost/libs/mpl/test/empty.cpp | 23 + src/boost/libs/mpl/test/empty_sequence.cpp | 39 ++ src/boost/libs/mpl/test/equal.cpp | 31 ++ src/boost/libs/mpl/test/erase.cpp | 45 ++ src/boost/libs/mpl/test/erase_range.cpp | 34 ++ src/boost/libs/mpl/test/eval_if.cpp | 33 ++ src/boost/libs/mpl/test/filter_view.cpp | 42 ++ src/boost/libs/mpl/test/find.cpp | 37 ++ src/boost/libs/mpl/test/find_if.cpp | 46 ++ src/boost/libs/mpl/test/fold.cpp | 55 +++ src/boost/libs/mpl/test/for_each.cpp | 81 ++++ src/boost/libs/mpl/test/front.cpp | 29 ++ src/boost/libs/mpl/test/get_tag_def.cpp | 32 ++ src/boost/libs/mpl/test/has_xxx.cpp | 158 +++++++ src/boost/libs/mpl/test/identity.cpp | 32 ++ src/boost/libs/mpl/test/if.cpp | 29 ++ src/boost/libs/mpl/test/index_of.cpp | 34 ++ src/boost/libs/mpl/test/inherit.cpp | 40 ++ src/boost/libs/mpl/test/insert.cpp | 31 ++ src/boost/libs/mpl/test/insert_range.cpp | 73 +++ src/boost/libs/mpl/test/int.cpp | 24 + src/boost/libs/mpl/test/integral_c.cpp | 30 ++ src/boost/libs/mpl/test/integral_wrapper_test.hpp | 63 +++ src/boost/libs/mpl/test/is_placeholder.cpp | 42 ++ src/boost/libs/mpl/test/is_sequence.cpp | 39 ++ src/boost/libs/mpl/test/iterator_tags.cpp | 23 + src/boost/libs/mpl/test/joint_view.cpp | 56 +++ src/boost/libs/mpl/test/lambda.cpp | 78 ++++ src/boost/libs/mpl/test/lambda_args.cpp | 48 ++ src/boost/libs/mpl/test/list.cpp | 68 +++ src/boost/libs/mpl/test/list_c.cpp | 81 ++++ src/boost/libs/mpl/test/logical.cpp | 41 ++ src/boost/libs/mpl/test/lower_bound.cpp | 28 ++ src/boost/libs/mpl/test/map.cpp | 235 ++++++++++ src/boost/libs/mpl/test/max_element.cpp | 26 ++ src/boost/libs/mpl/test/min_max.cpp | 27 ++ src/boost/libs/mpl/test/multiset.cpp | 107 +++++ src/boost/libs/mpl/test/next.cpp | 29 ++ src/boost/libs/mpl/test/no_has_xxx.cpp | 30 ++ src/boost/libs/mpl/test/numeric_ops.cpp | 155 +++++++ src/boost/libs/mpl/test/pair_view.cpp | 45 ++ src/boost/libs/mpl/test/partition.cpp | 42 ++ src/boost/libs/mpl/test/pop_front.cpp | 36 ++ src/boost/libs/mpl/test/print.cpp | 22 + src/boost/libs/mpl/test/push_back.cpp | 52 +++ src/boost/libs/mpl/test/push_front.cpp | 50 ++ src/boost/libs/mpl/test/quote.cpp | 42 ++ src/boost/libs/mpl/test/range_c.cpp | 60 +++ src/boost/libs/mpl/test/remove.cpp | 28 ++ src/boost/libs/mpl/test/remove_if.cpp | 54 +++ src/boost/libs/mpl/test/replace.cpp | 27 ++ src/boost/libs/mpl/test/replace_if.cpp | 33 ++ src/boost/libs/mpl/test/reverse.cpp | 32 ++ src/boost/libs/mpl/test/same_as.cpp | 23 + src/boost/libs/mpl/test/set.cpp | 347 ++++++++++++++ src/boost/libs/mpl/test/set_c.cpp | 106 +++++ src/boost/libs/mpl/test/single_view.cpp | 43 ++ src/boost/libs/mpl/test/size.cpp | 26 ++ src/boost/libs/mpl/test/size_t.cpp | 29 ++ src/boost/libs/mpl/test/sizeof.cpp | 28 ++ src/boost/libs/mpl/test/sort.cpp | 27 ++ src/boost/libs/mpl/test/stable_partition.cpp | 47 ++ src/boost/libs/mpl/test/string.cpp | 516 +++++++++++++++++++++ src/boost/libs/mpl/test/transform.cpp | 51 ++ src/boost/libs/mpl/test/transform_view.cpp | 40 ++ src/boost/libs/mpl/test/unique.cpp | 29 ++ src/boost/libs/mpl/test/unpack_args.cpp | 26 ++ src/boost/libs/mpl/test/upper_bound.cpp | 29 ++ src/boost/libs/mpl/test/vector.cpp | 124 +++++ src/boost/libs/mpl/test/vector_c.cpp | 66 +++ src/boost/libs/mpl/test/zip_view.cpp | 45 ++ 102 files changed, 6039 insertions(+) create mode 100644 src/boost/libs/mpl/test/Jamfile.v2 create mode 100644 src/boost/libs/mpl/test/advance.cpp create mode 100644 src/boost/libs/mpl/test/always.cpp create mode 100644 src/boost/libs/mpl/test/apply.cpp create mode 100644 src/boost/libs/mpl/test/apply_wrap.cpp create mode 100644 src/boost/libs/mpl/test/arithmetic.cpp create mode 100644 src/boost/libs/mpl/test/as_sequence.cpp create mode 100644 src/boost/libs/mpl/test/assert.cpp create mode 100644 src/boost/libs/mpl/test/assert_vc8.hpp create mode 100644 src/boost/libs/mpl/test/assert_vc8_p1.cpp create mode 100644 src/boost/libs/mpl/test/assert_vc8_p2.cpp create mode 100644 src/boost/libs/mpl/test/at.cpp create mode 100644 src/boost/libs/mpl/test/aux_/increased_arity.cpp create mode 100644 src/boost/libs/mpl/test/aux_/largest_int.cpp create mode 100644 src/boost/libs/mpl/test/aux_/msvc_is_class.cpp create mode 100644 src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp create mode 100644 src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp create mode 100644 src/boost/libs/mpl/test/aux_/template_arity.cpp create mode 100644 src/boost/libs/mpl/test/back.cpp create mode 100644 src/boost/libs/mpl/test/bind.cpp create mode 100644 src/boost/libs/mpl/test/bitwise.cpp create mode 100644 src/boost/libs/mpl/test/bool.cpp create mode 100644 src/boost/libs/mpl/test/char.cpp create mode 100644 src/boost/libs/mpl/test/comparison.cpp create mode 100644 src/boost/libs/mpl/test/contains.cpp create mode 100644 src/boost/libs/mpl/test/copy.cpp create mode 100644 src/boost/libs/mpl/test/copy_if.cpp create mode 100644 src/boost/libs/mpl/test/count.cpp create mode 100644 src/boost/libs/mpl/test/count_if.cpp create mode 100644 src/boost/libs/mpl/test/deque.cpp create mode 100644 src/boost/libs/mpl/test/distance.cpp create mode 100644 src/boost/libs/mpl/test/empty.cpp create mode 100644 src/boost/libs/mpl/test/empty_sequence.cpp create mode 100644 src/boost/libs/mpl/test/equal.cpp create mode 100644 src/boost/libs/mpl/test/erase.cpp create mode 100644 src/boost/libs/mpl/test/erase_range.cpp create mode 100644 src/boost/libs/mpl/test/eval_if.cpp create mode 100644 src/boost/libs/mpl/test/filter_view.cpp create mode 100644 src/boost/libs/mpl/test/find.cpp create mode 100644 src/boost/libs/mpl/test/find_if.cpp create mode 100644 src/boost/libs/mpl/test/fold.cpp create mode 100644 src/boost/libs/mpl/test/for_each.cpp create mode 100644 src/boost/libs/mpl/test/front.cpp create mode 100644 src/boost/libs/mpl/test/get_tag_def.cpp create mode 100644 src/boost/libs/mpl/test/has_xxx.cpp create mode 100644 src/boost/libs/mpl/test/identity.cpp create mode 100644 src/boost/libs/mpl/test/if.cpp create mode 100644 src/boost/libs/mpl/test/index_of.cpp create mode 100644 src/boost/libs/mpl/test/inherit.cpp create mode 100644 src/boost/libs/mpl/test/insert.cpp create mode 100644 src/boost/libs/mpl/test/insert_range.cpp create mode 100644 src/boost/libs/mpl/test/int.cpp create mode 100644 src/boost/libs/mpl/test/integral_c.cpp create mode 100644 src/boost/libs/mpl/test/integral_wrapper_test.hpp create mode 100644 src/boost/libs/mpl/test/is_placeholder.cpp create mode 100644 src/boost/libs/mpl/test/is_sequence.cpp create mode 100644 src/boost/libs/mpl/test/iterator_tags.cpp create mode 100644 src/boost/libs/mpl/test/joint_view.cpp create mode 100644 src/boost/libs/mpl/test/lambda.cpp create mode 100644 src/boost/libs/mpl/test/lambda_args.cpp create mode 100644 src/boost/libs/mpl/test/list.cpp create mode 100644 src/boost/libs/mpl/test/list_c.cpp create mode 100644 src/boost/libs/mpl/test/logical.cpp create mode 100644 src/boost/libs/mpl/test/lower_bound.cpp create mode 100644 src/boost/libs/mpl/test/map.cpp create mode 100644 src/boost/libs/mpl/test/max_element.cpp create mode 100644 src/boost/libs/mpl/test/min_max.cpp create mode 100644 src/boost/libs/mpl/test/multiset.cpp create mode 100644 src/boost/libs/mpl/test/next.cpp create mode 100644 src/boost/libs/mpl/test/no_has_xxx.cpp create mode 100644 src/boost/libs/mpl/test/numeric_ops.cpp create mode 100644 src/boost/libs/mpl/test/pair_view.cpp create mode 100644 src/boost/libs/mpl/test/partition.cpp create mode 100644 src/boost/libs/mpl/test/pop_front.cpp create mode 100644 src/boost/libs/mpl/test/print.cpp create mode 100644 src/boost/libs/mpl/test/push_back.cpp create mode 100644 src/boost/libs/mpl/test/push_front.cpp create mode 100644 src/boost/libs/mpl/test/quote.cpp create mode 100644 src/boost/libs/mpl/test/range_c.cpp create mode 100644 src/boost/libs/mpl/test/remove.cpp create mode 100644 src/boost/libs/mpl/test/remove_if.cpp create mode 100644 src/boost/libs/mpl/test/replace.cpp create mode 100644 src/boost/libs/mpl/test/replace_if.cpp create mode 100644 src/boost/libs/mpl/test/reverse.cpp create mode 100644 src/boost/libs/mpl/test/same_as.cpp create mode 100644 src/boost/libs/mpl/test/set.cpp create mode 100644 src/boost/libs/mpl/test/set_c.cpp create mode 100644 src/boost/libs/mpl/test/single_view.cpp create mode 100644 src/boost/libs/mpl/test/size.cpp create mode 100644 src/boost/libs/mpl/test/size_t.cpp create mode 100644 src/boost/libs/mpl/test/sizeof.cpp create mode 100644 src/boost/libs/mpl/test/sort.cpp create mode 100644 src/boost/libs/mpl/test/stable_partition.cpp create mode 100644 src/boost/libs/mpl/test/string.cpp create mode 100644 src/boost/libs/mpl/test/transform.cpp create mode 100644 src/boost/libs/mpl/test/transform_view.cpp create mode 100644 src/boost/libs/mpl/test/unique.cpp create mode 100644 src/boost/libs/mpl/test/unpack_args.cpp create mode 100644 src/boost/libs/mpl/test/upper_bound.cpp create mode 100644 src/boost/libs/mpl/test/vector.cpp create mode 100644 src/boost/libs/mpl/test/vector_c.cpp create mode 100644 src/boost/libs/mpl/test/zip_view.cpp (limited to 'src/boost/libs/mpl/test') diff --git a/src/boost/libs/mpl/test/Jamfile.v2 b/src/boost/libs/mpl/test/Jamfile.v2 new file mode 100644 index 00000000..1c8f393d --- /dev/null +++ b/src/boost/libs/mpl/test/Jamfile.v2 @@ -0,0 +1,98 @@ + +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 ; +# link assert_vc8_p1.cpp assert_vc8_p2.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 : : : vacpp:-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 ; diff --git a/src/boost/libs/mpl/test/advance.cpp b/src/boost/libs/mpl/test/advance.cpp new file mode 100644 index 00000000..e174ae4c --- /dev/null +++ b/src/boost/libs/mpl/test/advance.cpp @@ -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 +#include +#include + +template< int pos > struct iter +{ + typedef mpl::bidirectional_iterator_tag category; + typedef iter<(pos + 1)> next; + typedef iter<(pos - 1)> prior; + typedef int_ type; +}; + +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +namespace boost { namespace mpl { +template< int pos, typename Default > struct tag< iter,Default > : void_ {}; +}} +#endif + +typedef iter<0> first; +typedef iter<10> last; + +MPL_TEST_CASE() +{ + typedef mpl::advance >::type iter1; + typedef advance_c::type iter2; + + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); +} + +MPL_TEST_CASE() +{ + typedef mpl::advance >::type iter1; + typedef advance_c::type iter2; + + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); +} diff --git a/src/boost/libs/mpl/test/always.cpp b/src/boost/libs/mpl/test/always.cpp new file mode 100644 index 00000000..c879b973 --- /dev/null +++ b/src/boost/libs/mpl/test/always.cpp @@ -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 +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef always 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 ); +} diff --git a/src/boost/libs/mpl/test/apply.cpp b/src/boost/libs/mpl/test/apply.cpp new file mode 100644 index 00000000..71bcbf9e --- /dev/null +++ b/src/boost/libs/mpl/test/apply.cpp @@ -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 +#include +#include +#include +#include + + +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_<3> > plus1; + typedef lambda::type plus2; + MPL_ASSERT(( is_same< plus1,plus2 > )); + + typedef lambda >::type v; + MPL_ASSERT(( is_same< v,std_vector > )); + + typedef lambda >::type make_vector; + typedef apply_wrap1::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector > )); +} + +MPL_TEST_CASE() +{ + typedef plus<_1,_2> plus_fun; + typedef apply2,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,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 >::type v; + MPL_ASSERT(( is_same< v,std_vector > )); + + 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 > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< _1, std_vector >::type v; + MPL_ASSERT(( is_same< v,std_vector > )); + + typedef apply1< _1, std_vector<_1> >::type v_lambda; + typedef apply1::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< lambda<_1>, std_vector >::type v; + MPL_ASSERT(( is_same< v,std_vector > )); + + 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 > )); +} + +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,_1,_1> b1; + typedef lambda::type b2; + MPL_ASSERT(( is_same< b1,b2 > )); +} + +MPL_TEST_CASE() +{ +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + typedef lambda< lambda< bind2,_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,_1,_1>, int_<5> >::type res; + MPL_ASSERT_RELATION( res::value, ==, 10 ); +} + +MPL_TEST_CASE() +{ + typedef apply1<_1, lambda > >::type plus_fun; + typedef apply_wrap2< plus_fun::type, int_<2>,int_<3> >::type res; + + MPL_ASSERT_RELATION( res::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/apply_wrap.cpp b/src/boost/libs/mpl/test/apply_wrap.cpp new file mode 100644 index 00000000..9c45f2e1 --- /dev/null +++ b/src/boost/libs/mpl/test/apply_wrap.cpp @@ -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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#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_::type t; \ + { MPL_ASSERT(( boost::is_same )); } \ +/**/ + +#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 )); } \ + { MPL_ASSERT(( boost::is_same )); } \ +/**/ + +#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::type t; + MPL_ASSERT(( boost::is_same )); + } +#endif +} diff --git a/src/boost/libs/mpl/test/arithmetic.cpp b/src/boost/libs/mpl/test/arithmetic.cpp new file mode 100644 index 00000000..81a615f1 --- /dev/null +++ b/src/boost/libs/mpl/test/arithmetic.cpp @@ -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 +#include +#include + +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 ); +} diff --git a/src/boost/libs/mpl/test/as_sequence.cpp b/src/boost/libs/mpl/test/as_sequence.cpp new file mode 100644 index 00000000..65edb5d1 --- /dev/null +++ b/src/boost/libs/mpl/test/as_sequence.cpp @@ -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 +#include +#include + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_sequence< as_sequence::type > )); + MPL_ASSERT(( is_sequence< as_sequence::type > )); + MPL_ASSERT(( is_sequence< as_sequence< vector<> >::type > )); +} diff --git a/src/boost/libs/mpl/test/assert.cpp b/src/boost/libs/mpl/test/assert.cpp new file mode 100644 index 00000000..b20f699d --- /dev/null +++ b/src/boost/libs/mpl/test/assert.cpp @@ -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 + +#include +#include + + +BOOST_MPL_ASSERT(( boost::is_same )); +BOOST_MPL_ASSERT(( boost::is_pointer )); +BOOST_MPL_ASSERT_NOT(( boost::is_same )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer )); +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 )); +BOOST_MPL_ASSERT(( boost::is_pointer )); +BOOST_MPL_ASSERT_NOT(( boost::is_same )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer )); +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 )); + BOOST_MPL_ASSERT(( boost::is_pointer )); + BOOST_MPL_ASSERT_NOT(( boost::is_same )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer )); + 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) ); +#endif + + void f() + { + BOOST_MPL_ASSERT(( boost::is_same )); + BOOST_MPL_ASSERT(( boost::is_pointer )); + BOOST_MPL_ASSERT_NOT(( boost::is_same )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer )); + 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) ); +#endif + } +}; + +template +struct nested : boost::mpl::true_ { + BOOST_MPL_ASSERT(( boost::is_pointer )); + BOOST_MPL_ASSERT_NOT(( boost::is_same )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +}; + +BOOST_MPL_ASSERT(( nested )); +BOOST_MPL_ASSERT_NOT(( boost::mpl::not_ > )); + +int main() +{ + her h; + h.f(); + + BOOST_MPL_ASSERT(( boost::is_same )); + BOOST_MPL_ASSERT(( boost::is_pointer )); + BOOST_MPL_ASSERT_NOT(( boost::is_same )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer )); + 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; +} diff --git a/src/boost/libs/mpl/test/assert_vc8.hpp b/src/boost/libs/mpl/test/assert_vc8.hpp new file mode 100644 index 00000000..f54df0e1 --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8.hpp @@ -0,0 +1,28 @@ + +// Copyright Robin Linden 2018 +// +// 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$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include + +template +bool func() +{ + BOOST_MPL_ASSERT_MSG( + true, + ALWAYS_TRUE, + (T)); + + return true; +} diff --git a/src/boost/libs/mpl/test/assert_vc8_p1.cpp b/src/boost/libs/mpl/test/assert_vc8_p1.cpp new file mode 100644 index 00000000..2883135a --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8_p1.cpp @@ -0,0 +1,23 @@ + +// Copyright Robin Linden 2018 +// +// 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$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func(); + +int main() +{ +} diff --git a/src/boost/libs/mpl/test/assert_vc8_p2.cpp b/src/boost/libs/mpl/test/assert_vc8_p2.cpp new file mode 100644 index 00000000..6b535734 --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8_p2.cpp @@ -0,0 +1,19 @@ + +// Copyright Robin Linden 2018 +// +// 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$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func(); diff --git a/src/boost/libs/mpl/test/at.cpp b/src/boost/libs/mpl/test/at.cpp new file mode 100644 index 00000000..4b30edab --- /dev/null +++ b/src/boost/libs/mpl/test/at.cpp @@ -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 +#include +#include + +template< typename Seq, int n > struct at_test +{ + typedef typename at_c::type t; + MPL_ASSERT(( is_same< t, integral_c > )); + MPL_ASSERT_RELATION( t::value, ==, 9 - n ); +}; + +MPL_TEST_CASE() +{ + typedef vector10_c 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 >(); +} diff --git a/src/boost/libs/mpl/test/aux_/increased_arity.cpp b/src/boost/libs/mpl/test/aux_/increased_arity.cpp new file mode 100644 index 00000000..47a433d6 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/increased_arity.cpp @@ -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 +#include +#include + +#include + +#include +#include +#include +#include + +#define TEST_N_ARY(unused1, N, unused2) \ + static_assert_< \ + apply< \ + and_, \ + BOOST_PP_ENUM_PARAMS(N, true_ BOOST_PP_INTERCEPT) \ + > \ + >(); \ +/**/ + +template +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, + _ + ) +} diff --git a/src/boost/libs/mpl/test/aux_/largest_int.cpp b/src/boost/libs/mpl/test/aux_/largest_int.cpp new file mode 100644 index 00000000..d9a6fd34 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/largest_int.cpp @@ -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 +#include + + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same< mpl::aux::largest_int::type, bool > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int::type, char > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int::type, char > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int::type, unsigned > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int::type, long > )); +} diff --git a/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp b/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp new file mode 100644 index 00000000..6e5d49ea --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp @@ -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 +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + +#include +#include + +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 > )); + MPL_ASSERT(( aux::msvc_is_class< A > )); +} + +#endif diff --git a/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp b/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp new file mode 100644 index 00000000..c860efc9 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp @@ -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 + +#include +#include + +#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 ) diff --git a/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp b/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp new file mode 100644 index 00000000..442199a0 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp @@ -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 + +#include +#include + +#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 ) diff --git a/src/boost/libs/mpl/test/aux_/template_arity.cpp b/src/boost/libs/mpl/test/aux_/template_arity.cpp new file mode 100644 index 00000000..22370d7c --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/template_arity.cpp @@ -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 +#include + +#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::value), ==, -1 ); + MPL_ASSERT_RELATION( (aux::template_arity< my1 >::value), ==, 1 ); + MPL_ASSERT_RELATION( (aux::template_arity< my2 >::value), ==, 2 ); + MPL_ASSERT_RELATION( (aux::template_arity< my2 >::value), ==, 2 ); +} + +#endif diff --git a/src/boost/libs/mpl/test/back.cpp b/src/boost/libs/mpl/test/back.cpp new file mode 100644 index 00000000..84ae1e88 --- /dev/null +++ b/src/boost/libs/mpl/test/back.cpp @@ -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 +#include +#include + +template< typename Seq, int value > struct back_test +{ + typedef typename back::type t; + MPL_ASSERT_RELATION( t::value, ==, value ); +}; + +MPL_TEST_CASE() +{ + back_test< range_c, 0 >(); + back_test< range_c, 9 >(); + back_test< range_c, -1 >(); +} diff --git a/src/boost/libs/mpl/test/bind.cpp b/src/boost/libs/mpl/test/bind.cpp new file mode 100644 index 00000000..2a2de62c --- /dev/null +++ b/src/boost/libs/mpl/test/bind.cpp @@ -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 +#include +#include +#include +#include +#include +#include + +#include + +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, int >::type r11; + typedef apply_wrap5< bind1, void,void,void,void,int >::type r12; + MPL_ASSERT(( boost::is_same )); + MPL_ASSERT(( boost::is_same )); + + typedef apply_wrap5< bind5, void,void,void,void,int >::type r51; + typedef apply_wrap5< bind5, int,void,void,void,void >::type r52; + MPL_ASSERT(( boost::is_same )); + MPL_ASSERT(( boost::is_same )); +} + + +MPL_TEST_CASE() // fully bound metafunction classes +{ + typedef apply_wrap0< bind1 >::type r11; + typedef apply_wrap0< bind5 >::type r51; + MPL_ASSERT(( boost::is_same )); + MPL_ASSERT(( boost::is_same )); +} + + +MPL_TEST_CASE() // metafunction class composition +{ + typedef apply_wrap5< bind5 >, int,void,void,void,void >::type r51; + typedef apply_wrap5< bind5 >, void,void,void,void,int >::type r52; + MPL_ASSERT(( boost::is_same )); + MPL_ASSERT(( boost::is_same )); +} + +#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, _1, bind1< quote1, _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 > )); + MPL_ASSERT(( boost::is_same > )); +} +#endif diff --git a/src/boost/libs/mpl/test/bitwise.cpp b/src/boost/libs/mpl/test/bitwise.cpp new file mode 100644 index 00000000..8e6e32bf --- /dev/null +++ b/src/boost/libs/mpl/test/bitwise.cpp @@ -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 +#include +#include + +typedef integral_c _0; +typedef integral_c _1; +typedef integral_c _2; +typedef integral_c _8; +typedef integral_c _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(bitor_<_0,_ffffffff>::value), ==, static_cast(0xffffffff) ); + MPL_ASSERT_RELATION( static_cast(bitor_<_1,_ffffffff>::value), ==, static_cast(0xffffffff) ); + MPL_ASSERT_RELATION( static_cast(bitor_<_8,_ffffffff>::value), ==, static_cast(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(bitxor_<_0,_ffffffff>::value), ==, static_cast(0xffffffff ^ 0) ); + MPL_ASSERT_RELATION( static_cast(bitxor_<_1,_ffffffff>::value), ==, static_cast(0xffffffff ^ 1) ); + MPL_ASSERT_RELATION( static_cast(bitxor_<_8,_ffffffff>::value), ==, static_cast(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 ); +} diff --git a/src/boost/libs/mpl/test/bool.cpp b/src/boost/libs/mpl/test/bool.cpp new file mode 100644 index 00000000..e023c0ca --- /dev/null +++ b/src/boost/libs/mpl/test/bool.cpp @@ -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 +#include + +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) +#define CONSTEXPR_BOOL_TEST(c) +#else +#define CONSTEXPR_BOOL_TEST(c) { static_assert(bool_() == c, "Constexpr for bool_ failed"); } +#endif + +#define BOOL_TEST(c) \ + { MPL_ASSERT(( is_same< bool_::value_type, bool > )); } \ + { MPL_ASSERT(( is_same< bool_, c##_ > )); } \ + { MPL_ASSERT(( is_same< bool_::type, bool_ > )); } \ + { MPL_ASSERT_RELATION( bool_::value, ==, c ); } \ + CONSTEXPR_BOOL_TEST(c) \ + BOOST_TEST( bool_() == c ); \ +/**/ + +MPL_TEST_CASE() +{ + BOOL_TEST(true) + BOOL_TEST(false) +} diff --git a/src/boost/libs/mpl/test/char.cpp b/src/boost/libs/mpl/test/char.cpp new file mode 100644 index 00000000..39f61e73 --- /dev/null +++ b/src/boost/libs/mpl/test/char.cpp @@ -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 +#include + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) char_ + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char) +} diff --git a/src/boost/libs/mpl/test/comparison.cpp b/src/boost/libs/mpl/test/comparison.cpp new file mode 100644 index 00000000..a59a1046 --- /dev/null +++ b/src/boost/libs/mpl/test/comparison.cpp @@ -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 +#include +#include + +// 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> )); +} diff --git a/src/boost/libs/mpl/test/contains.cpp b/src/boost/libs/mpl/test/contains.cpp new file mode 100644 index 00000000..1452a387 --- /dev/null +++ b/src/boost/libs/mpl/test/contains.cpp @@ -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 +#include +#include + +MPL_TEST_CASE() +{ + typedef vector::type types; + + MPL_ASSERT(( contains< types,short > )); + MPL_ASSERT_NOT(( contains< types,unsigned > )); +} diff --git a/src/boost/libs/mpl/test/copy.cpp b/src/boost/libs/mpl/test/copy.cpp new file mode 100644 index 00000000..a776f55c --- /dev/null +++ b/src/boost/libs/mpl/test/copy.cpp @@ -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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef vector10_c answer; + typedef copy< + range_c + , mpl::front_inserter< vector0<> > + >::type result; + + MPL_ASSERT_RELATION( size::value, ==, 10 ); + MPL_ASSERT(( equal< result,answer > )); +} + +MPL_TEST_CASE() +{ + typedef vector10_c numbers; + typedef reverse_copy< + range_c + , mpl::front_inserter + >::type result; + + MPL_ASSERT_RELATION( size::value, ==, 20 ); + MPL_ASSERT(( equal< result,range_c > )); +} + +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,int_<10> > + { + }; +}; + +}} + +MPL_TEST_CASE() +{ + typedef vector10_c numbers; + typedef copy< push_back_only< numbers > >::type result; + + MPL_ASSERT((equal< numbers, result >)); +} diff --git a/src/boost/libs/mpl/test/copy_if.cpp b/src/boost/libs/mpl/test/copy_if.cpp new file mode 100644 index 00000000..698b4d7a --- /dev/null +++ b/src/boost/libs/mpl/test/copy_if.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list10_c::type numbers; + typedef list5_c::type answer; + typedef copy_if< + numbers + , less<_,int_<5> > + , mpl::front_inserter< list0_c > + >::type result; + + MPL_ASSERT_RELATION(size::value, ==, 5); + MPL_ASSERT(( equal )); +} + + +MPL_TEST_CASE() +{ + typedef list8::type types; + typedef list4::type float_types; + typedef reverse_copy_if< + types + , is_float<_> + , mpl::front_inserter< list0<> > + >::type result; + + MPL_ASSERT_RELATION(mpl::size::value, ==, 4); + MPL_ASSERT(( equal )); +} diff --git a/src/boost/libs/mpl/test/count.cpp b/src/boost/libs/mpl/test/count.cpp new file mode 100644 index 00000000..7d96fee3 --- /dev/null +++ b/src/boost/libs/mpl/test/count.cpp @@ -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 + +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef vector types; + + MPL_ASSERT_RELATION( (count::value), ==, 1 ); + MPL_ASSERT_RELATION( (count::value), ==, 1 ); + MPL_ASSERT_RELATION( (count::value), ==, 2 ); + MPL_ASSERT_RELATION( (count::value), ==, 3 ); + MPL_ASSERT_RELATION( (count::value), ==, 0 ); +} + +MPL_TEST_CASE() +{ + typedef vector_c values; + + MPL_ASSERT_RELATION( (count< values, integral_c >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count< values, integral_c >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count< values, integral_c >::value), ==, 3 ); + MPL_ASSERT_RELATION( (count< values, integral_c >::value), ==, 1 ); + MPL_ASSERT_RELATION( (count< values, integral_c >::value), ==, 0 ); +} diff --git a/src/boost/libs/mpl/test/count_if.cpp b/src/boost/libs/mpl/test/count_if.cpp new file mode 100644 index 00000000..598ffeeb --- /dev/null +++ b/src/boost/libs/mpl/test/count_if.cpp @@ -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 +#include +#include +#include +#include +#include + +#include +#include + +MPL_TEST_CASE() +{ + typedef vector types; + typedef vector_c 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,_> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count_if< values, equal_to,_> >::value), ==, 0 ); +} diff --git a/src/boost/libs/mpl/test/deque.cpp b/src/boost/libs/mpl/test/deque.cpp new file mode 100644 index 00000000..4ac747cd --- /dev/null +++ b/src/boost/libs/mpl/test/deque.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef deque<> d0; + typedef deque d1; + typedef deque d2; + typedef deque d9; + + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 9 ); + + MPL_ASSERT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,char > )); + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,long > )); + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,int > )); +} + + +MPL_TEST_CASE() +{ + typedef deque d2; + + typedef begin::type i1; + typedef next::type i2; + typedef next::type i3; + + MPL_ASSERT(( is_same::type,char> )); + MPL_ASSERT(( is_same::type,long> )); + MPL_ASSERT(( is_same< i3, end::type > )); +} + +MPL_TEST_CASE() +{ + typedef deque<> d0; + + typedef push_back::type d1; + MPL_ASSERT(( is_same< back::type,int > )); + + typedef push_front::type d2; + MPL_ASSERT(( is_same< back::type,int > )); + MPL_ASSERT(( is_same< front::type,char > )); + + typedef push_back::type d3; + MPL_ASSERT(( is_same< back::type,long > )); +} + +MPL_TEST_CASE() +{ + typedef deque<> d0; + typedef deque d1; + typedef deque d2; + typedef deque d9; + + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 9 ); +} diff --git a/src/boost/libs/mpl/test/distance.cpp b/src/boost/libs/mpl/test/distance.cpp new file mode 100644 index 00000000..879dd53e --- /dev/null +++ b/src/boost/libs/mpl/test/distance.cpp @@ -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 +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef list::type list; + typedef begin::type first; + typedef end::type last; + + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 4 ); +} + +MPL_TEST_CASE() +{ + typedef range_c::type range; + typedef begin::type first; + typedef end::type last; + + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 10 ); +} diff --git a/src/boost/libs/mpl/test/empty.cpp b/src/boost/libs/mpl/test/empty.cpp new file mode 100644 index 00000000..7e73b361 --- /dev/null +++ b/src/boost/libs/mpl/test/empty.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + MPL_ASSERT(( empty< list0<> > )); + MPL_ASSERT_NOT(( empty< list1 > )); +} diff --git a/src/boost/libs/mpl/test/empty_sequence.cpp b/src/boost/libs/mpl/test/empty_sequence.cpp new file mode 100644 index 00000000..2fa989fa --- /dev/null +++ b/src/boost/libs/mpl/test/empty_sequence.cpp @@ -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 +#include +#include +#include +#include +#include +#include + +#include +#include + +MPL_TEST_CASE() +{ + typedef begin::type begin; + typedef end::type end; + + MPL_ASSERT(( is_same )); + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 0 ); + + typedef advance_c::type advanced; + MPL_ASSERT(( is_same )); + + MPL_ASSERT(( equal< empty_sequence, empty_sequence::type > )); +} diff --git a/src/boost/libs/mpl/test/equal.cpp b/src/boost/libs/mpl/test/equal.cpp new file mode 100644 index 00000000..19390efe --- /dev/null +++ b/src/boost/libs/mpl/test/equal.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + typedef list list1; + typedef list list2; + typedef list list3; + typedef list list4; + + MPL_ASSERT(( equal )); + MPL_ASSERT(( equal )); + MPL_ASSERT_NOT(( equal )); + MPL_ASSERT_NOT(( equal )); + MPL_ASSERT_NOT(( equal )); +} diff --git a/src/boost/libs/mpl/test/erase.cpp b/src/boost/libs/mpl/test/erase.cpp new file mode 100644 index 00000000..ca5b411b --- /dev/null +++ b/src/boost/libs/mpl/test/erase.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list types; + typedef find::type iter; + + typedef erase::type result; + MPL_ASSERT_RELATION( size::value, ==, 7 ); + + typedef find::type result_iter; + MPL_ASSERT(( is_same< result_iter, end::type > )); +} + +MPL_TEST_CASE() +{ + typedef list_c values; + typedef find< values, integral_c >::type iter; + + typedef erase::type result; + MPL_ASSERT_RELATION( size::value, ==, 7 ); + + typedef find >::type result_iter; + MPL_ASSERT(( is_same< result_iter, end::type > )); +} diff --git a/src/boost/libs/mpl/test/erase_range.cpp b/src/boost/libs/mpl/test/erase_range.cpp new file mode 100644 index 00000000..5e14c819 --- /dev/null +++ b/src/boost/libs/mpl/test/erase_range.cpp @@ -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 +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list types; + + typedef find::type iter1; + typedef find::type iter2; + + typedef erase::type result; + + MPL_ASSERT_RELATION( size::value, ==, 5 ); + + typedef find::type iter; + MPL_ASSERT(( is_same< iter, end::type > )); +} diff --git a/src/boost/libs/mpl/test/eval_if.cpp b/src/boost/libs/mpl/test/eval_if.cpp new file mode 100644 index 00000000..e2b4332c --- /dev/null +++ b/src/boost/libs/mpl/test/eval_if.cpp @@ -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 +#include +#include + +#include + +#include + +MPL_TEST_CASE() +{ + typedef eval_if< true_, identity, identity >::type t1; + typedef eval_if_c< true, identity, identity >::type t2; + typedef eval_if< false_, identity, identity >::type t3; + typedef eval_if_c< false, identity, identity >::type t4; + + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); +} diff --git a/src/boost/libs/mpl/test/filter_view.cpp b/src/boost/libs/mpl/test/filter_view.cpp new file mode 100644 index 00000000..2ae57540 --- /dev/null +++ b/src/boost/libs/mpl/test/filter_view.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +MPL_TEST_CASE() +{ + typedef mpl::list types; + typedef mpl::list 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::type, long double>)); +} diff --git a/src/boost/libs/mpl/test/find.cpp b/src/boost/libs/mpl/test/find.cpp new file mode 100644 index 00000000..a45d5216 --- /dev/null +++ b/src/boost/libs/mpl/test/find.cpp @@ -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 +#include +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list::type types; + typedef list_c values; + + typedef find::type types_iter; + typedef find< values, integral_c >::type values_iter; + + MPL_ASSERT(( is_same< deref::type, short> )); + MPL_ASSERT_RELATION( deref::type::value, ==, 7 ); + + typedef begin::type types_first; + typedef begin::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 ); +} diff --git a/src/boost/libs/mpl/test/find_if.cpp b/src/boost/libs/mpl/test/find_if.cpp new file mode 100644 index 00000000..0d0ce89e --- /dev/null +++ b/src/boost/libs/mpl/test/find_if.cpp @@ -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 + +#include +#include +#include +#include + +#include +#include + +typedef vector::type types; +typedef begin::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::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::value), ==, 2 ); +} + +MPL_TEST_CASE() +{ + typedef find_if< types, boost::is_same<_,void> >::type iter; + MPL_ASSERT(( is_same< iter, end::type > )); + MPL_ASSERT_RELATION( (mpl::distance::value), ==, size::value ); +} diff --git a/src/boost/libs/mpl/test/fold.cpp b/src/boost/libs/mpl/test/fold.cpp new file mode 100644 index 00000000..48f47587 --- /dev/null +++ b/src/boost/libs/mpl/test/fold.cpp @@ -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 +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list 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 numbers; + typedef list_c negatives; + typedef reverse_fold< + numbers + , list_c + , if_< less< _2,int_<0> >, push_front<_1,_2>, _1 > + >::type result; + + MPL_ASSERT(( equal< result,negatives,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/for_each.cpp b/src/boost/libs/mpl/test/for_each.cpp new file mode 100644 index 00000000..ec7a3d50 --- /dev/null +++ b/src/boost/libs/mpl/test/for_each.cpp @@ -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 + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace mpl = boost::mpl; + +struct type_printer +{ + type_printer(std::ostream& s) : f_stream(&s) {} + template< typename U > void operator()(mpl::identity) + { + *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* c, int i) +{ + c->push_back(i); +} + +int main() +{ + typedef mpl::list types; + mpl::for_each< types,mpl::make_identity >(type_printer(std::cout)); + + typedef mpl::range_c numbers; + std::vector v; + + mpl::for_each( + 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; +} diff --git a/src/boost/libs/mpl/test/front.cpp b/src/boost/libs/mpl/test/front.cpp new file mode 100644 index 00000000..b28dffed --- /dev/null +++ b/src/boost/libs/mpl/test/front.cpp @@ -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 +#include +#include + +template< typename Seq, int value > struct front_test +{ + typedef typename front::type t; + MPL_ASSERT_RELATION( t::value, ==, value ); +}; + +MPL_TEST_CASE() +{ + front_test< range_c, 1 >(); + front_test< range_c, 2 >(); + front_test< range_c, -1 >(); +} diff --git a/src/boost/libs/mpl/test/get_tag_def.cpp b/src/boost/libs/mpl/test/get_tag_def.cpp new file mode 100644 index 00000000..eb160dd8 --- /dev/null +++ b/src/boost/libs/mpl/test/get_tag_def.cpp @@ -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 +#include +#include +#include + + +struct test_type_get_tag_def +{ + typedef int a_tag; +}; + +BOOST_MPL_GET_TAG_DEF(a_tag); + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same::type> )); + MPL_ASSERT(( is_same::type> )); +} diff --git a/src/boost/libs/mpl/test/has_xxx.cpp b/src/boost/libs/mpl/test/has_xxx.cpp new file mode 100644 index 00000000..c466db27 --- /dev/null +++ b/src/boost/libs/mpl/test/has_xxx.cpp @@ -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 +#include +#include + +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 )); + MPL_ASSERT_NOT(( has_xxx_template )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT(( has_xxx_template )); +#endif + MPL_ASSERT_NOT(( has_xxx< enum_ > )); + MPL_ASSERT_NOT(( has_xxx_template< enum_ > )); +#endif + + MPL_ASSERT_NOT(( has_xxx )); + MPL_ASSERT_NOT(( has_xxx_template )); + + MPL_ASSERT_NOT(( has_xxx< outer< inner > > )); + MPL_ASSERT_NOT(( has_xxx_template< outer< inner > > )); + + 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 )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); +#endif + + // Same name, different args. + MPL_ASSERT(( has_xxx_template )); + MPL_ASSERT(( has_xxx_template )); + MPL_ASSERT(( has_xxx_template )); + MPL_ASSERT(( has_xxx_template )); + MPL_ASSERT(( has_xxx_template )); + MPL_ASSERT(( has_yyy )); + MPL_ASSERT(( has_yyy )); + + // Different name, different args. + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_xxx_template )); + MPL_ASSERT_NOT(( has_yyy )); + MPL_ASSERT_NOT(( has_yyy )); + MPL_ASSERT_NOT(( has_yyy )); + MPL_ASSERT_NOT(( has_yyy )); + MPL_ASSERT_NOT(( has_yyy )); + + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + MPL_ASSERT(( has_xxx )); + + MPL_ASSERT(( has_xxx_template )); + +#if !defined(HAS_XXX_ASSERT) +# define HAS_XXX_ASSERT(x) MPL_ASSERT(x) +#endif + + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + HAS_XXX_ASSERT(( has_xxx )); + +#if !defined(HAS_XXX_TEMPLATE_ASSERT) +# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT(x) +#endif + + HAS_XXX_TEMPLATE_ASSERT(( has_xxx_template )); +} diff --git a/src/boost/libs/mpl/test/identity.cpp b/src/boost/libs/mpl/test/identity.cpp new file mode 100644 index 00000000..db147358 --- /dev/null +++ b/src/boost/libs/mpl/test/identity.cpp @@ -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 +#include +#include + +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 > )); + MPL_ASSERT(( is_same< t2, identity > )); +} diff --git a/src/boost/libs/mpl/test/if.cpp b/src/boost/libs/mpl/test/if.cpp new file mode 100644 index 00000000..df32b6a5 --- /dev/null +++ b/src/boost/libs/mpl/test/if.cpp @@ -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 +#include +#include + +MPL_TEST_CASE() +{ + typedef if_::type t1; + typedef if_c::type t2; + typedef if_::type t3; + typedef if_c::type t4; + + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); +} diff --git a/src/boost/libs/mpl/test/index_of.cpp b/src/boost/libs/mpl/test/index_of.cpp new file mode 100644 index 00000000..bffd3218 --- /dev/null +++ b/src/boost/libs/mpl/test/index_of.cpp @@ -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 +#include +#include +#include + +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 > )); +} diff --git a/src/boost/libs/mpl/test/inherit.cpp b/src/boost/libs/mpl/test/inherit.cpp new file mode 100644 index 00000000..4b16adc5 --- /dev/null +++ b/src/boost/libs/mpl/test/inherit.cpp @@ -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 +#include + +struct her { typedef her herself; }; +struct my { typedef my myself; }; + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same::type, her> )); + + typedef inherit::type her_my1; + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + + typedef inherit::type her1; + MPL_ASSERT(( is_same )); + + typedef inherit::type her2; + MPL_ASSERT(( is_same )); + + typedef inherit::type her_my2; + MPL_ASSERT(( is_same )); + MPL_ASSERT(( is_same )); + + typedef inherit::type empty; + MPL_ASSERT(( is_same )); +} diff --git a/src/boost/libs/mpl/test/insert.cpp b/src/boost/libs/mpl/test/insert.cpp new file mode 100644 index 00000000..f293cbba --- /dev/null +++ b/src/boost/libs/mpl/test/insert.cpp @@ -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 + +#include +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef vector_c numbers; + typedef find< numbers,integral_c >::type pos; + typedef insert< numbers,pos,integral_c >::type range; + + MPL_ASSERT_RELATION( size::value, ==, 10 ); + MPL_ASSERT(( equal< range,range_c > )); +} diff --git a/src/boost/libs/mpl/test/insert_range.cpp b/src/boost/libs/mpl/test/insert_range.cpp new file mode 100644 index 00000000..865017b7 --- /dev/null +++ b/src/boost/libs/mpl/test/insert_range.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef vector_c numbers; + typedef find< numbers,integral_c >::type pos; + typedef insert_range< numbers,pos,range_c >::type range; + + MPL_ASSERT_RELATION( size::value, ==, 10 ); + MPL_ASSERT(( equal< range,range_c > )); + + typedef insert_range< list0<>,end< list0<> >::type,list1 >::type result2; + MPL_ASSERT_RELATION( size::value, ==, 1 ); +} + +template +void test_associative() +{ + typedef typename insert_range< A,typename end< A >::type,B >::type C; + + MPL_ASSERT_RELATION( size::value, <=, (size::value + size::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(); + + typedef set_c< int,1,3,5,7,9 > odds; + typedef set_c< int,0,2,4,6,8 > evens; + test_associative(); + + 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(); +} diff --git a/src/boost/libs/mpl/test/int.cpp b/src/boost/libs/mpl/test/int.cpp new file mode 100644 index 00000000..6c1e24b2 --- /dev/null +++ b/src/boost/libs/mpl/test/int.cpp @@ -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 +#include + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) int_ + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int) +} diff --git a/src/boost/libs/mpl/test/integral_c.cpp b/src/boost/libs/mpl/test/integral_c.cpp new file mode 100644 index 00000000..a9f9b0c2 --- /dev/null +++ b/src/boost/libs/mpl/test/integral_c.cpp @@ -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 +#include + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) integral_c + +#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) +} diff --git a/src/boost/libs/mpl/test/integral_wrapper_test.hpp b/src/boost/libs/mpl/test/integral_wrapper_test.hpp new file mode 100644 index 00000000..be31d505 --- /dev/null +++ b/src/boost/libs/mpl/test/integral_wrapper_test.hpp @@ -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 +#include +#include + +#include + +#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 + diff --git a/src/boost/libs/mpl/test/is_placeholder.cpp b/src/boost/libs/mpl/test/is_placeholder.cpp new file mode 100644 index 00000000..b90b3a3c --- /dev/null +++ b/src/boost/libs/mpl/test/is_placeholder.cpp @@ -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 +#include +#include + +#include +#include +#include + +#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 )); + MPL_ASSERT_NOT(( is_placeholder )); + MPL_ASSERT_NOT(( is_placeholder )); + MPL_ASSERT_NOT(( is_placeholder )); + MPL_ASSERT_NOT(( is_placeholder )); + MPL_ASSERT(( is_placeholder<_> )); + + BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , AUX_IS_PLACEHOLDER_TEST + , unused + ) +} diff --git a/src/boost/libs/mpl/test/is_sequence.cpp b/src/boost/libs/mpl/test/is_sequence.cpp new file mode 100644 index 00000000..1efa8175 --- /dev/null +++ b/src/boost/libs/mpl/test/is_sequence.cpp @@ -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 +#include +#include +#include +#include +#include + +template< typename T > struct std_vector +{ + T* begin(); +}; + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( is_sequence< std_vector > )); + 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 > )); + MPL_ASSERT(( is_sequence< list<> > )); + MPL_ASSERT(( is_sequence< list > )); + MPL_ASSERT(( is_sequence< vector<> > )); + MPL_ASSERT(( is_sequence< vector > )); +} diff --git a/src/boost/libs/mpl/test/iterator_tags.cpp b/src/boost/libs/mpl/test/iterator_tags.cpp new file mode 100644 index 00000000..6840161c --- /dev/null +++ b/src/boost/libs/mpl/test/iterator_tags.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + MPL_ASSERT(( less )); + MPL_ASSERT(( less )); +} diff --git a/src/boost/libs/mpl/test/joint_view.cpp b/src/boost/libs/mpl/test/joint_view.cpp new file mode 100644 index 00000000..17f824c6 --- /dev/null +++ b/src/boost/libs/mpl/test/joint_view.cpp @@ -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 + +#include +#include +#include +#include +#include + + +MPL_TEST_CASE() +{ + typedef joint_view< + range_c + , range_c + > numbers; + + typedef range_c answer; + + MPL_ASSERT(( equal )); + MPL_ASSERT(( equal )); + MPL_ASSERT_RELATION( size::value, ==, 15 ); +} + +template< typename View > struct test_is_empty +{ + typedef typename begin::type first_; + typedef typename end::type last_; + + MPL_ASSERT_RELATION( size::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<> > > >(); +} diff --git a/src/boost/libs/mpl/test/lambda.cpp b/src/boost/libs/mpl/test/lambda.cpp new file mode 100644 index 00000000..22e6236c --- /dev/null +++ b/src/boost/libs/mpl/test/lambda.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +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 )); + MPL_ASSERT_NOT(( apply_wrap1 )); + MPL_ASSERT(( apply_wrap1 )); + MPL_ASSERT(( apply_wrap1 )); +} + +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 )); + MPL_ASSERT_NOT(( apply_wrap2 )); + MPL_ASSERT_NOT(( apply_wrap2 )); + MPL_ASSERT(( apply_wrap2 )); + MPL_ASSERT(( apply_wrap2 )); + MPL_ASSERT(( apply_wrap2 )); +} + +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> > )); +} diff --git a/src/boost/libs/mpl/test/lambda_args.cpp b/src/boost/libs/mpl/test/lambda_args.cpp new file mode 100644 index 00000000..fdd26205 --- /dev/null +++ b/src/boost/libs/mpl/test/lambda_args.cpp @@ -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 +#include +#include +#include +#include + +typedef int UDT::* mem_ptr; +typedef int (UDT::* mem_fun_ptr)(); + +#define AUX_LAMBDA_TEST(T) \ + { MPL_ASSERT(( apply1 >::type, T> )); } \ + { MPL_ASSERT(( apply1 >::type, T> )); } \ + { MPL_ASSERT(( apply2 >::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 ); +} diff --git a/src/boost/libs/mpl/test/list.cpp b/src/boost/libs/mpl/test/list.cpp new file mode 100644 index 00000000..655905a1 --- /dev/null +++ b/src/boost/libs/mpl/test/list.cpp @@ -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 +#include +#include +#include +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef list0<> l0; + typedef list1 l1; + typedef list2 l2; + typedef list9 l9; + + MPL_ASSERT_RELATION(size::value, ==, 0); + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 2); + MPL_ASSERT_RELATION(size::value, ==, 9); + + MPL_ASSERT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same::type,char> )); + MPL_ASSERT(( is_same::type,char> )); + MPL_ASSERT(( is_same::type,char> )); +} + +MPL_TEST_CASE() +{ + typedef list2 l2; + + typedef begin::type i1; + typedef next::type i2; + typedef next::type i3; + + MPL_ASSERT(( is_same::type,char> )); + MPL_ASSERT(( is_same::type,long> )); + MPL_ASSERT(( is_same< i3, end::type > )); +} + +MPL_TEST_CASE() +{ + typedef list0<> l0; + + typedef push_front::type l1; + MPL_ASSERT(( is_same::type,char> )); + + typedef push_front::type l2; + MPL_ASSERT(( is_same::type,long> )); +} diff --git a/src/boost/libs/mpl/test/list_c.cpp b/src/boost/libs/mpl/test/list_c.cpp new file mode 100644 index 00000000..7683fda0 --- /dev/null +++ b/src/boost/libs/mpl/test/list_c.cpp @@ -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 +#include +#include +#include + +#include + + +#if !BOOST_WORKAROUND(BOOST_MSVC,<= 1200) +MPL_TEST_CASE() +{ + typedef list_c::type l1; + typedef list_c::type l2; + + MPL_ASSERT(( is_same< l1::value_type, bool > )); + MPL_ASSERT(( is_same< l2::value_type, bool > )); + + MPL_ASSERT_RELATION( front::type::value, ==, true ); + MPL_ASSERT_RELATION( front::type::value, ==, false ); +} +#endif + +MPL_TEST_CASE() +{ + typedef list_c::type l1; + typedef list_c::type l2; + typedef list_c::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::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 3 ); + MPL_ASSERT_RELATION( front::type::value, ==, -1 ); + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef list_c::type l1; + typedef list_c::type l2; + + MPL_ASSERT(( is_same< l1::value_type, unsigned > )); + MPL_ASSERT(( is_same< l2::value_type, unsigned > )); + + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef list_c l2; + + MPL_ASSERT(( is_same< l2::value_type, unsigned > )); + + typedef begin::type i1; + typedef next::type i2; + typedef next::type i3; + + MPL_ASSERT_RELATION( deref::type::value, ==, 2 ); + MPL_ASSERT_RELATION( deref::type::value, ==, 1 ); + MPL_ASSERT(( is_same< i3, end::type > )); +} diff --git a/src/boost/libs/mpl/test/logical.cpp b/src/boost/libs/mpl/test/logical.cpp new file mode 100644 index 00000000..bea6b7ac --- /dev/null +++ b/src/boost/libs/mpl/test/logical.cpp @@ -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 +#include +#include + +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_ > )); +} diff --git a/src/boost/libs/mpl/test/lower_bound.cpp b/src/boost/libs/mpl/test/lower_bound.cpp new file mode 100644 index 00000000..95be40de --- /dev/null +++ b/src/boost/libs/mpl/test/lower_bound.cpp @@ -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 +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list_c numbers; + typedef lower_bound< numbers, int_<4> >::type iter; + + MPL_ASSERT_RELATION( (mpl::distance< begin::type,iter >::value), ==, 5 ); + MPL_ASSERT_RELATION( deref::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/map.cpp b/src/boost/libs/mpl/test/map.cpp new file mode 100644 index 00000000..f39b85d8 --- /dev/null +++ b/src/boost/libs/mpl/test/map.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef map2< + mpl::pair + , mpl::pair + > m_; + + typedef erase_key::type m; + + MPL_ASSERT_RELATION( size::type::value, ==, 1 ); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT(( is_same< clear::type,map0<> > )); + + MPL_ASSERT(( is_same< at::type,unsigned > )); + MPL_ASSERT(( is_same< at::type,void_ > )); + MPL_ASSERT(( contains< m,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m,mpl::pair > )); + + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT(( has_key::type )); + + MPL_ASSERT_NOT(( is_same< order::type, void_ > )); + MPL_ASSERT(( is_same< order::type,void_ > )); + + typedef begin::type first; + typedef end::type last; + + MPL_ASSERT(( is_same< deref::type,mpl::pair > )); + MPL_ASSERT(( is_same< next::type,last > )); + + typedef insert >::type m2; + + MPL_ASSERT_RELATION( size::type::value, ==, 2 ); + MPL_ASSERT_NOT(( empty::type )); + MPL_ASSERT(( is_same< clear::type,map0<> > )); + MPL_ASSERT(( is_same< at::type,unsigned > )); + MPL_ASSERT(( is_same< at::type,long > )); + + MPL_ASSERT(( contains< m2,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m2,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m2,mpl::pair > )); + MPL_ASSERT(( contains< m2,mpl::pair > )); + + MPL_ASSERT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( is_same< order::type, void_ > )); + MPL_ASSERT_NOT(( is_same< order::type, void_ > )); + MPL_ASSERT_NOT(( is_same< order::type, order::type > )); + + typedef begin::type first2; + typedef end::type last2; + + MPL_ASSERT(( is_same::type,mpl::pair > )); + typedef next::type iter; + MPL_ASSERT(( is_same::type,mpl::pair > )); + MPL_ASSERT(( is_same< next::type,last2 > )); + + typedef insert >::type s2_1; + MPL_ASSERT(( is_same )); + + typedef insert >::type m3; + MPL_ASSERT_RELATION( size::type::value, ==, 3 ); + MPL_ASSERT(( has_key::type )); + MPL_ASSERT(( has_key::type )); + MPL_ASSERT(( has_key::type )); + MPL_ASSERT(( contains< m3,mpl::pair > )); + MPL_ASSERT(( contains< m3,mpl::pair > )); + + typedef insert >::type m1; + MPL_ASSERT_RELATION( size::type::value, ==, 2 ); + MPL_ASSERT(( is_same< at::type,unsigned > )); + MPL_ASSERT(( is_same< at::type,long > )); + + MPL_ASSERT(( contains< m1,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m1,mpl::pair > )); + MPL_ASSERT_NOT(( contains< m1,mpl::pair > )); + MPL_ASSERT(( contains< m1,mpl::pair > )); + + MPL_ASSERT(( is_same< m1,m2 > )); + + typedef erase_key::type m_1; + MPL_ASSERT(( is_same )); + MPL_ASSERT_RELATION( size::type::value, ==, 1 ); + MPL_ASSERT(( is_same< at::type,void_ > )); + MPL_ASSERT(( is_same< at::type,unsigned > )); + + typedef erase_key::type m2_1; + MPL_ASSERT_RELATION( size::type::value, ==, 2 ); + MPL_ASSERT(( is_same< at::type,void_ > )); + MPL_ASSERT(( is_same< at::type,unsigned > )); + MPL_ASSERT(( is_same< at::type,unsigned > )); +} + +MPL_TEST_CASE() +{ + typedef map0<> m; + + MPL_ASSERT_RELATION( size::type::value, ==, 0 ); + MPL_ASSERT(( empty::type )); + + MPL_ASSERT(( is_same< clear::type,map0<> > )); + MPL_ASSERT(( is_same< at::type,void_ > )); + + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + MPL_ASSERT_NOT(( has_key::type )); + + typedef insert >::type m1; + MPL_ASSERT_RELATION( size::type::value, ==, 1 ); + MPL_ASSERT(( is_same< at::type,int > )); + + typedef erase_key::type m0_1; + MPL_ASSERT_RELATION( size::type::value, ==, 0 ); + MPL_ASSERT(( is_same< at::type,void_ > )); +} + +// Use a template for testing so that GCC will show us the actual types involved +template +void test() +{ + MPL_ASSERT_RELATION( size::value, ==, 3 ); + + typedef typename end::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same >::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same >::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same >::type,not_found> )); + BOOST_MPL_ASSERT(( is_same::type,not_found> )); +}; + +MPL_TEST_CASE() +{ + typedef map< mpl::pair > map_of_1_pair; + typedef begin::type iter_to_1_pair; + + BOOST_MPL_ASSERT(( + is_same< + deref::type + , mpl::pair + > + )); + + typedef map< + mpl::pair + , mpl::pair + , mpl::pair + > mymap; + + test(); + test(); +} + +MPL_TEST_CASE() +{ + typedef mpl::erase_key< + mpl::map< + mpl::pair + , mpl::pair + > + , char + >::type int_to_float_map; + + typedef mpl::insert< + int_to_float_map + , mpl::pair + >::type with_char_too; + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::at::type + , long + > + )); +} + +MPL_TEST_CASE() +{ + typedef insert< map<>, pair >::type little_map; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} + +MPL_TEST_CASE() +{ + typedef erase_key< map< pair, pair >, float >::type little_map; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} diff --git a/src/boost/libs/mpl/test/max_element.cpp b/src/boost/libs/mpl/test/max_element.cpp new file mode 100644 index 00000000..65bb0f3a --- /dev/null +++ b/src/boost/libs/mpl/test/max_element.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + typedef list_c::type numbers; + typedef max_element< numbers >::type iter; + typedef deref::type max_value; + + MPL_ASSERT_RELATION( max_value::value, ==, 8 ); +} diff --git a/src/boost/libs/mpl/test/min_max.cpp b/src/boost/libs/mpl/test/min_max.cpp new file mode 100644 index 00000000..02ead233 --- /dev/null +++ b/src/boost/libs/mpl/test/min_max.cpp @@ -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 +#include + +#include + + +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> > )); +} diff --git a/src/boost/libs/mpl/test/multiset.cpp b/src/boost/libs/mpl/test/multiset.cpp new file mode 100644 index 00000000..48a6176e --- /dev/null +++ b/src/boost/libs/mpl/test/multiset.cpp @@ -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 +//#include + +#include +#include +#include + +#include +#include +#include + +#include + +/* +struct test_data1 +{ + typedef multiset0<> s0; + typedef multiset1 s1; + typedef multiset2 s2; + typedef multiset3 s3; + typedef multiset4 s4; +}; + +struct test_data2 +{ + typedef multiset<> s0; + typedef multiset s1; + typedef multiset s2; + typedef multiset s3; + typedef multiset s4; +}; +*/ + +template< typename S0 > +struct test_data +{ + typedef S0 s0; + typedef typename insert::type s1; + typedef typename insert::type s2; + typedef typename insert::type s3; + typedef typename insert::type s4; +}; + + +template< typename T > +void count_test() +{ + MPL_ASSERT_RELATION( ( count::value ), ==, 0 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 2 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count::value ), ==, 1 ); +} + +MPL_TEST_CASE() +{ + //count_test(); + //count_test(); + //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 +void find_test() +{ + BOOST_MPL_ASSERT_RELATION( size::value, ==, 3 ); + + typedef typename end::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT(( is_same::type,not_found> )); +} +*/ + +MPL_TEST_CASE() +{ + // agurt 11/jun/06: multiset does not implement iterators yet! + // typedef insert, int>::type set_of_1_int; + // typedef begin::type iter_to_1_int; + // BOOST_MPL_ASSERT(( is_same< deref::type, int > )); + + typedef multiset0<> s0; + typedef insert::type s1; + typedef insert::type s2; + typedef insert::type myset; + + // find_test(); + // find_test(); +} diff --git a/src/boost/libs/mpl/test/next.cpp b/src/boost/libs/mpl/test/next.cpp new file mode 100644 index 00000000..d7356c72 --- /dev/null +++ b/src/boost/libs/mpl/test/next.cpp @@ -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 +#include +#include +#include + +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 > )); +} diff --git a/src/boost/libs/mpl/test/no_has_xxx.cpp b/src/boost/libs/mpl/test/no_has_xxx.cpp new file mode 100644 index 00000000..53e4691f --- /dev/null +++ b/src/boost/libs/mpl/test/no_has_xxx.cpp @@ -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 + +#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" diff --git a/src/boost/libs/mpl/test/numeric_ops.cpp b/src/boost/libs/mpl/test/numeric_ops.cpp new file mode 100644 index 00000000..453b4aab --- /dev/null +++ b/src/boost/libs/mpl/test/numeric_ops.cpp @@ -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 +#include +#include +#include +#include +#include + +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::type r1; + MPL_ASSERT_RELATION( real::value, ==, 0 ); + MPL_ASSERT_RELATION( imag::value, ==, 0 ); + + typedef plus::type r2; + MPL_ASSERT_RELATION( real::value, ==, 10 ); + MPL_ASSERT_RELATION( imag::value, ==, -2 ); + + typedef plus::type r3; + MPL_ASSERT_RELATION( real::value, ==, -10 ); + MPL_ASSERT_RELATION( imag::value, ==, 2 ); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + typedef plus::type r4; + MPL_ASSERT_RELATION( real::value, ==, 7 ); + MPL_ASSERT_RELATION( imag::value, ==, -1 ); + + typedef plus::type r5; + MPL_ASSERT_RELATION( real::value, ==, -3 ); + MPL_ASSERT_RELATION( imag::value, ==, 1 ); +#endif +} + +MPL_TEST_CASE() +{ + typedef times::type r1; + MPL_ASSERT_RELATION( real::value, ==, -24 ); + MPL_ASSERT_RELATION( imag::value, ==, 10 ); + + typedef times::type r2; + MPL_ASSERT_RELATION( real::value, ==, 24 ); + MPL_ASSERT_RELATION( imag::value, ==, -10 ); + + typedef times::type r3; + MPL_ASSERT_RELATION( real::value, ==, 24 ); + MPL_ASSERT_RELATION( imag::value, ==, -10 ); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + typedef times::type r4; + MPL_ASSERT_RELATION( real::value, ==, 10 ); + MPL_ASSERT_RELATION( imag::value, ==, -2 ); + + typedef times::type r5; + MPL_ASSERT_RELATION( real::value, ==, -10 ); + MPL_ASSERT_RELATION( imag::value, ==, 2 ); +#endif +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( equal_to )); + MPL_ASSERT(( equal_to )); + MPL_ASSERT_NOT(( equal_to )); + + MPL_ASSERT(( equal_to, long_<-1> > > )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + MPL_ASSERT_NOT(( equal_to )); + MPL_ASSERT_NOT(( equal_to )); +#endif +} diff --git a/src/boost/libs/mpl/test/pair_view.cpp b/src/boost/libs/mpl/test/pair_view.cpp new file mode 100644 index 00000000..937ff427 --- /dev/null +++ b/src/boost/libs/mpl/test/pair_view.cpp @@ -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 +#include +#include +#include +#include + + +MPL_TEST_CASE() +{ + typedef range_c r; + typedef vector10_c v; + + typedef pair_view view; + typedef begin::type first_; + typedef end::type last_; + + MPL_ASSERT(( is_same< first_::category, mpl::random_access_iterator_tag > )); + + MPL_ASSERT(( is_same< advance_c::type, first_ > )); + MPL_ASSERT(( is_same< advance_c::type, last_ > )); + MPL_ASSERT(( is_same< advance_c::type, last_ > )); + MPL_ASSERT(( is_same< advance_c::type, first_ > )); + + typedef advance_c::type iter; + + MPL_ASSERT(( is_same< + deref::type + , mpl::pair< integral_c,integral_c > + > )); + +} diff --git a/src/boost/libs/mpl/test/partition.cpp b/src/boost/libs/mpl/test/partition.cpp new file mode 100644 index 00000000..947c310d --- /dev/null +++ b/src/boost/libs/mpl/test/partition.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +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 + , is_odd<_1> + , mpl::back_inserter< vector<> > + , mpl::back_inserter< vector<> > + >::type r; + + MPL_ASSERT(( equal< r::first, vector_c > )); + MPL_ASSERT(( equal< r::second, vector_c > )); +} diff --git a/src/boost/libs/mpl/test/pop_front.cpp b/src/boost/libs/mpl/test/pop_front.cpp new file mode 100644 index 00000000..71512c10 --- /dev/null +++ b/src/boost/libs/mpl/test/pop_front.cpp @@ -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 +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list::type types1; + typedef list::type types2; + typedef list::type types3; + + typedef pop_front::type result1; + typedef pop_front::type result2; + typedef pop_front::type result3; + + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + + MPL_ASSERT(( is_same< front::type, long > )); + MPL_ASSERT(( is_same< front::type, int > )); +} diff --git a/src/boost/libs/mpl/test/print.cpp b/src/boost/libs/mpl/test/print.cpp new file mode 100644 index 00000000..12295df3 --- /dev/null +++ b/src/boost/libs/mpl/test/print.cpp @@ -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 + +#include + + +MPL_TEST_CASE() +{ + typedef print::type t; +} diff --git a/src/boost/libs/mpl/test/push_back.cpp b/src/boost/libs/mpl/test/push_back.cpp new file mode 100644 index 00000000..bdf7a920 --- /dev/null +++ b/src/boost/libs/mpl/test/push_back.cpp @@ -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 + +#include + +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 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 > )); +} diff --git a/src/boost/libs/mpl/test/push_front.cpp b/src/boost/libs/mpl/test/push_front.cpp new file mode 100644 index 00000000..f5edc2f9 --- /dev/null +++ b/src/boost/libs/mpl/test/push_front.cpp @@ -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 +#include +#include +#include +#include + +#include + +struct no_push_front_tag {}; + +struct no_push_front +{ + typedef no_push_front_tag tag; +}; + +MPL_TEST_CASE() +{ + typedef push_front,long>::type res1; + typedef push_front,int>::type res2; + typedef push_front,char>::type res3; + + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 3 ); + + MPL_ASSERT(( is_same< front::type, long > )); + MPL_ASSERT(( is_same< front::type, int > )); + MPL_ASSERT(( is_same< front::type, char > )); + + MPL_ASSERT(( has_push_front< list0<> > )); + MPL_ASSERT(( has_push_front< list1 > )); + + MPL_ASSERT_NOT(( has_push_back< list0<> > )); + + MPL_ASSERT_NOT(( has_push_front< no_push_front > )); +} diff --git a/src/boost/libs/mpl/test/quote.cpp b/src/boost/libs/mpl/test/quote.cpp new file mode 100644 index 00000000..45e97f8d --- /dev/null +++ b/src/boost/libs/mpl/test/quote.cpp @@ -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 +#include +#include + +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::apply::type t1; + typedef quote5::apply::type t5; + + MPL_ASSERT(( boost::is_same< t1, int > )); + MPL_ASSERT(( boost::is_same< t5, f5 > )); +} diff --git a/src/boost/libs/mpl/test/range_c.cpp b/src/boost/libs/mpl/test/range_c.cpp new file mode 100644 index 00000000..90c32cc4 --- /dev/null +++ b/src/boost/libs/mpl/test/range_c.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef range_c range0; + typedef range_c range1; + typedef range_c range10; + + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 10 ); + + MPL_ASSERT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same< begin::type, end::type > )); + MPL_ASSERT_NOT(( is_same::type, end::type > )); + MPL_ASSERT_NOT(( is_same::type, end::type > )); + + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( back::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( back::type::value, ==, 9 ); +} + +MPL_TEST_CASE() +{ + typedef range_c r; + typedef begin::type first; + typedef end::type last; + + MPL_ASSERT(( is_same< advance_c::type, last > )); + MPL_ASSERT(( is_same< advance_c::type, first > )); + + MPL_ASSERT_RELATION( ( mpl::distance::value ), ==, 10 ); + + typedef advance_c::type iter; + MPL_ASSERT_RELATION( deref::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/remove.cpp b/src/boost/libs/mpl/test/remove.cpp new file mode 100644 index 00000000..6147b08d --- /dev/null +++ b/src/boost/libs/mpl/test/remove.cpp @@ -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 +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef vector6 types; + typedef mpl::remove< types,float >::type result; + typedef vector3 answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/remove_if.cpp b/src/boost/libs/mpl/test/remove_if.cpp new file mode 100644 index 00000000..bf9d0eae --- /dev/null +++ b/src/boost/libs/mpl/test/remove_if.cpp @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list10_c numbers; + typedef list5_c::type answer; + typedef remove_if< + numbers + , greater<_,int_<4> > + , mpl::front_inserter< list0_c > + >::type result; + + MPL_ASSERT_RELATION( size::value, ==, 5 ); + MPL_ASSERT(( equal )); +} + +MPL_TEST_CASE() +{ + typedef list8 types; + typedef list4::type answer; + typedef reverse_remove_if< + types + , is_float<_> + , mpl::front_inserter< list0<> > + >::type result; + + MPL_ASSERT_RELATION( size::value, ==, 4 ); + MPL_ASSERT(( equal )); +} diff --git a/src/boost/libs/mpl/test/replace.cpp b/src/boost/libs/mpl/test/replace.cpp new file mode 100644 index 00000000..4b3005be --- /dev/null +++ b/src/boost/libs/mpl/test/replace.cpp @@ -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 + +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list types; + typedef replace< types,float,double >::type result; + typedef list answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/replace_if.cpp b/src/boost/libs/mpl/test/replace_if.cpp new file mode 100644 index 00000000..4fc690d9 --- /dev/null +++ b/src/boost/libs/mpl/test/replace_if.cpp @@ -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 + +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list8_c::type numbers; + typedef replace_if< numbers, greater<_1,int_<4> >, int_<0> >::type result; + + typedef list8_c::type answer; + MPL_ASSERT(( equal< answer,result,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/reverse.cpp b/src/boost/libs/mpl/test/reverse.cpp new file mode 100644 index 00000000..69b4a432 --- /dev/null +++ b/src/boost/libs/mpl/test/reverse.cpp @@ -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 + +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list_c numbers; + typedef reverse< numbers >::type result; + + typedef range_c answer; + + MPL_ASSERT(( equal< result,answer,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/same_as.cpp b/src/boost/libs/mpl/test/same_as.cpp new file mode 100644 index 00000000..41a7c573 --- /dev/null +++ b/src/boost/libs/mpl/test/same_as.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + MPL_ASSERT(( apply1< same_as,int > )); + MPL_ASSERT_NOT(( apply1< same_as,long > )); +} diff --git a/src/boost/libs/mpl/test/set.cpp b/src/boost/libs/mpl/test/set.cpp new file mode 100644 index 00000000..0710b41b --- /dev/null +++ b/src/boost/libs/mpl/test/set.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +// 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::value, ==, 0 ); + MPL_ASSERT(( empty )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::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::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT(( is_same )); + MPL_ASSERT_RELATION( (distance::value), ==, 0 ); +} + + +template< typename s > +void int_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::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::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME deref::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME next::type, last > )); + + MPL_ASSERT_RELATION( (distance::value), ==, 1 ); + MPL_ASSERT(( contains< s, int > )); +} + + +template< typename s > +void int_char_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, char > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::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::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT_RELATION( (distance::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::value, ==, 3 ); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, char > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, long > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::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::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + MPL_ASSERT_RELATION( (distance::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(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , int + >::type >(); + + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , long + >::type + , int + >::type >(); + + + int_set_test(); + int_set_test< BOOST_DEDUCED_TYPENAME insert::type >(); + + int_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + int_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , long + >::type >(); + + int_char_set_test(); + int_char_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , int + >::type >(); + + int_char_set_test< BOOST_DEDUCED_TYPENAME insert::type >(); + int_char_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + + int_char_long_set_test(); + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , long + >::type + , int + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , char + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert::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 s11; + typedef mpl::set s12; + typedef mpl::set2 s21; + typedef mpl::set s22; + typedef mpl::set s23; + typedef mpl::set3 s31; + typedef mpl::set s32; + typedef mpl::set s33; + typedef mpl::set s34; + + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + + basic_set_test(); + basic_set_test(); + basic_set_test(); + basic_set_test(); + basic_set_test(); +} + + +template< typename s > +void empty_set_types_variety_test() +{ + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); +} + +template< typename s > +void set_types_variety_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 8 ); + + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); +} + + +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(); + set_types_variety_test(); +} + + +template +void find_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 3 ); + + typedef typename end::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT(( is_same::type,not_found> )); +} + +MPL_TEST_CASE() +{ + typedef mpl::set s; + find_test(); + find_test(); +} + +MPL_TEST_CASE() +{ + typedef insert< set<>, int >::type little_set; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} + +MPL_TEST_CASE() +{ + typedef erase_key< set< float, int >, float >::type little_set; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} diff --git a/src/boost/libs/mpl/test/set_c.cpp b/src/boost/libs/mpl/test/set_c.cpp new file mode 100644 index 00000000..e34d86de --- /dev/null +++ b/src/boost/libs/mpl/test/set_c.cpp @@ -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 +#include +#include +#include + +#include + +namespace test { namespace { +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +template< typename S, typename S::value_type k > +struct at_c + : at< S, integral_c >::type +{ +}; +#else +template< typename S, long k > +struct at_c + : aux::msvc_eti_base< + at< S, integral_c > + > +{ +}; +#endif +}} + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +MPL_TEST_CASE() +{ + typedef set_c::type s1; + typedef set_c::type s2; + typedef set_c::type s3; + + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::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::value ), ==, true ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, false ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, true ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, false ); + + MPL_ASSERT(( is_same< test::at_c::type, void_ > )); + MPL_ASSERT(( is_same< test::at_c::type, void_ > )); +#endif + + typedef begin::type first1; + typedef end::type last1; + MPL_ASSERT_RELATION( (distance::value), ==, 1 ); + + typedef begin::type first2; + typedef end::type last2; + MPL_ASSERT_RELATION( (distance::value), ==, 1 ); + + typedef begin::type first3; + typedef end::type last3; + MPL_ASSERT_RELATION( (distance::value), ==, 2 ); +} +#endif + +MPL_TEST_CASE() +{ + typedef set_c::type s1; + typedef set_c::type s2; + + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::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::value ), ==, 'a' ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, 'a' ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, 'd' ); + MPL_ASSERT_RELATION( ( test::at_c::value ), ==, 'h' ); + + MPL_ASSERT(( is_same< test::at_c::type, void_ > )); + MPL_ASSERT(( is_same< test::at_c::type, void_ > )); +#endif + + typedef begin::type first1; + typedef end::type last1; + MPL_ASSERT_RELATION( (distance::value), ==, 1 ); + + typedef begin::type first2; + typedef end::type last2; + MPL_ASSERT_RELATION( (distance::value), ==, 8 ); +} diff --git a/src/boost/libs/mpl/test/single_view.cpp b/src/boost/libs/mpl/test/single_view.cpp new file mode 100644 index 00000000..18169d35 --- /dev/null +++ b/src/boost/libs/mpl/test/single_view.cpp @@ -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 +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef single_view view; + typedef begin::type first; + typedef end::type last; + + MPL_ASSERT(( is_same< deref::type, int > )); + MPL_ASSERT(( is_same< next::type, last > )); + MPL_ASSERT(( is_same< prior::type, first > )); + + MPL_ASSERT(( is_same< mpl::advance >::type, first > )); + MPL_ASSERT(( is_same< mpl::advance >::type, last > )); + MPL_ASSERT(( is_same< mpl::advance >::type, last > )); + MPL_ASSERT(( is_same< mpl::advance >::type, first > )); + + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 0 ); + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 1 ); + MPL_ASSERT_RELATION( (mpl::distance::value), ==, 0 ); + + MPL_ASSERT_RELATION( size::value, ==, 1 ); + + MPL_ASSERT(( equal< view, view::type > )); +} diff --git a/src/boost/libs/mpl/test/size.cpp b/src/boost/libs/mpl/test/size.cpp new file mode 100644 index 00000000..0c80711e --- /dev/null +++ b/src/boost/libs/mpl/test/size.cpp @@ -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 + +#include +#include + +MPL_TEST_CASE() +{ + typedef list<> empty_list; + typedef list list; + + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 4 ); +} diff --git a/src/boost/libs/mpl/test/size_t.cpp b/src/boost/libs/mpl/test/size_t.cpp new file mode 100644 index 00000000..c53194ba --- /dev/null +++ b/src/boost/libs/mpl/test/size_t.cpp @@ -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 +#endif + +#include +#include +#include + +#include "integral_wrapper_test.hpp" + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) mpl::size_t + BOOST_PP_REPEAT_FROM_TO(1, 11, INTEGRAL_WRAPPER_TEST, std::size_t) +} diff --git a/src/boost/libs/mpl/test/sizeof.cpp b/src/boost/libs/mpl/test/sizeof.cpp new file mode 100644 index 00000000..21c0ce02 --- /dev/null +++ b/src/boost/libs/mpl/test/sizeof.cpp @@ -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 +#include + +struct my +{ + char a[100]; +}; + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( sizeof_::value, ==, sizeof(char) ); + MPL_ASSERT_RELATION( sizeof_::value, ==, sizeof(int) ); + MPL_ASSERT_RELATION( sizeof_::value, ==, sizeof(double) ); + MPL_ASSERT_RELATION( sizeof_::value, ==, sizeof(my) ); +} diff --git a/src/boost/libs/mpl/test/sort.cpp b/src/boost/libs/mpl/test/sort.cpp new file mode 100644 index 00000000..e461f703 --- /dev/null +++ b/src/boost/libs/mpl/test/sort.cpp @@ -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 + +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list_c::type numbers; + typedef list_c::type manual_result; + + typedef sort< numbers >::type result; + + MPL_ASSERT(( equal< result,manual_result,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/stable_partition.cpp b/src/boost/libs/mpl/test/stable_partition.cpp new file mode 100644 index 00000000..e72d453a --- /dev/null +++ b/src/boost/libs/mpl/test/stable_partition.cpp @@ -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 + +#include +#include +#include +#include +#include + +typedef vector_c::type numbers; +typedef vector_c::type manual_first; +typedef vector_c::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 > )); +} diff --git a/src/boost/libs/mpl/test/string.cpp b/src/boost/libs/mpl/test/string.cpp new file mode 100644 index 00000000..57b5979d --- /dev/null +++ b/src/boost/libs/mpl/test/string.cpp @@ -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 +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mpl = boost::mpl; + +// Accept a string as a template parameter! +template +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 >::value)); + BOOST_MPL_ASSERT_RELATION(1, ==, (mpl::size >::value)); + BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size >::value)); + BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size >::value)); + BOOST_MPL_ASSERT_RELATION(4, ==, (mpl::size >::value)); + BOOST_MPL_ASSERT_RELATION(5, ==, (mpl::size >::value)); + BOOST_MPL_ASSERT_RELATION(31, ==, (mpl::size::value)); + BOOST_MPL_ASSERT_RELATION(32, ==, (mpl::size::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 >::type + , mpl::end >::type + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin >::type + , mpl::string_iterator, 0, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end >::type + , mpl::string_iterator, 1, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin::type + , mpl::string_iterator + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end::type + , mpl::string_iterator + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin::type + , mpl::string_iterator + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end::type + , mpl::string_iterator + > + )); + } + + // testing push_back + { + typedef mpl::push_back, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t2; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t3; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t4; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t5; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::push_back >::type t6; + BOOST_MPL_ASSERT((boost::is_same >)); + } + + // Test mpl::next + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::begin::type i0; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i1; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i2; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i3; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i4; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i5; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i6; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i7; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i8; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i9; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::next::type i10; + BOOST_MPL_ASSERT((boost::is_same >)); + + BOOST_MPL_ASSERT((boost::is_same::type>)); + } + + // Test mpl::prior + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::end::type i10; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i9; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i8; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i7; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i6; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i5; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i4; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i3; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i2; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i1; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::prior::type i0; + BOOST_MPL_ASSERT((boost::is_same >)); + + BOOST_MPL_ASSERT((boost::is_same::type>)); + } + + // Test mpl::deref + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::begin::type i0; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'a'> >)); + + typedef mpl::next::type i1; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'b'> >)); + + typedef mpl::next::type i2; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'c'> >)); + + typedef mpl::next::type i3; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'d'> >)); + + typedef mpl::next::type i4; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'e'> >)); + + typedef mpl::next::type i5; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'f'> >)); + + typedef mpl::next::type i6; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'g'> >)); + + typedef mpl::next::type i7; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'h'> >)); + + typedef mpl::next::type i8; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'i'> >)); + + typedef mpl::next::type i9; + BOOST_MPL_ASSERT((boost::is_same::type, mpl::char_<'j'> >)); + } + + // testing push_back + { + typedef mpl::push_back, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t2; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t3; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t4; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_back >::type t5; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::push_back >::type t6; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::string<'a','a','a','a','a','a','a','aaaa'> must_repack; + typedef mpl::push_back >::type t7; + BOOST_MPL_ASSERT((boost::is_same >)); + } + + BOOST_MPL_ASSERT((mpl::empty >)); + BOOST_MPL_ASSERT_NOT((mpl::empty >)); + + // testing push_front + { + typedef mpl::push_front, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_front >::type t2; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_front >::type t3; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_front >::type t4; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::push_front >::type t5; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> almost_full; + typedef mpl::push_front >::type t6; + BOOST_MPL_ASSERT((boost::is_same >)); + + typedef mpl::string<'aaaa','a','a','a','a','a','a','a'> must_repack; + typedef mpl::push_front >::type t7; + BOOST_MPL_ASSERT((boost::is_same >)); + } + + // Test c_str<> + BOOST_TEST(0 == std::strcmp( + mpl::c_str >::value + , "" + )); + + BOOST_TEST(0 == std::strcmp( + mpl::c_str >::value + , "Hell" "o wo" "rld!" + )); + + BOOST_TEST(0 == std::strcmp( + mpl::c_str >::value + , "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaX" + )); + + // test using a string as a template parameter + greeting >::value> g; + BOOST_TEST("Hello world!" == g.say_hello()); + + std::string result; + mpl::for_each >(push_char(result)); + BOOST_TEST("Hello world!" == result); + + BOOST_TEST(('h' == mpl::front >::type())); + BOOST_TEST(('!' == mpl::back >::type())); + + // back-inserter with copy + typedef mpl::vector_c rgc; + BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str::value)); + typedef mpl::copy > >::type str; + BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str::value)); + + // test insert_range and erase + { + typedef mpl::string<'Hell','o wo','rld!'> hello; + typedef mpl::advance_c::type, 5>::type where; + typedef mpl::string<' cru','el'> cruel; + typedef mpl::insert_range::type hello_cruel; + BOOST_TEST(0 == std::strcmp("Hello cruel world!", mpl::c_str::value)); + + typedef mpl::erase::type, where>::type erased1; + BOOST_TEST(0 == std::strcmp(" world!", mpl::c_str::value)); + } + + // test pop_front + { + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'b'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'bc'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'bcd'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'bcd','e'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'e'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front >::type + , mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> + > + )); + } + + // test pop_back + { + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<'a'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<'ab'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<'abc'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<'abcd'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::type + , mpl::string<'d'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back >::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(); +} diff --git a/src/boost/libs/mpl/test/transform.cpp b/src/boost/libs/mpl/test/transform.cpp new file mode 100644 index 00000000..8df17f20 --- /dev/null +++ b/src/boost/libs/mpl/test/transform.cpp @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef list types; + typedef list pointers; + + typedef transform1< types,add_pointer<_1> >::type result; + MPL_ASSERT(( equal )); +} + +MPL_TEST_CASE() +{ + typedef list_c evens; + typedef list_c primes; + typedef list_c 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 )); +#endif +} diff --git a/src/boost/libs/mpl/test/transform_view.cpp b/src/boost/libs/mpl/test/transform_view.cpp new file mode 100644 index 00000000..ff8fe6b5 --- /dev/null +++ b/src/boost/libs/mpl/test/transform_view.cpp @@ -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 + +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list types; + typedef list< + sizeof_::type, + sizeof_::type, + sizeof_::type, + sizeof_::type, + sizeof_::type + > sizes; + + MPL_ASSERT(( equal< transform_view< types, sizeof_<_> >::type,sizes > )); + + typedef max_element< + transform_view< types, sizeof_<_> > + >::type iter; + + MPL_ASSERT_RELATION( deref::type::value, ==, 50 ); +} diff --git a/src/boost/libs/mpl/test/unique.cpp b/src/boost/libs/mpl/test/unique.cpp new file mode 100644 index 00000000..2e1baa71 --- /dev/null +++ b/src/boost/libs/mpl/test/unique.cpp @@ -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 +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef list types; + typedef unique< types, is_same<_1,_2> >::type result; + + typedef list::type answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/unpack_args.cpp b/src/boost/libs/mpl/test/unpack_args.cpp new file mode 100644 index 00000000..d506535e --- /dev/null +++ b/src/boost/libs/mpl/test/unpack_args.cpp @@ -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 + +#include +#include +#include + +MPL_TEST_CASE() +{ + MPL_ASSERT(( apply1< + unpack_args< is_same<_1,_2> > + , vector2 + > )); +} diff --git a/src/boost/libs/mpl/test/upper_bound.cpp b/src/boost/libs/mpl/test/upper_bound.cpp new file mode 100644 index 00000000..7d6ea3bb --- /dev/null +++ b/src/boost/libs/mpl/test/upper_bound.cpp @@ -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 + +#include +#include +#include +#include +#include + +MPL_TEST_CASE() +{ + typedef list_c numbers; + typedef upper_bound< numbers, int_<3> >::type iter; + + MPL_ASSERT_RELATION( (mpl::distance< begin::type,iter >::value), ==, 5 ); + MPL_ASSERT_RELATION( deref::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/vector.cpp b/src/boost/libs/mpl/test/vector.cpp new file mode 100644 index 00000000..e1f6e0cb --- /dev/null +++ b/src/boost/libs/mpl/test/vector.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +MPL_TEST_CASE() +{ + typedef vector0<> v0; + typedef vector1 v1; + typedef vector2 v2; + typedef vector9 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::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 9 ); + + MPL_ASSERT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,char > )); + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,long > )); + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::type,int > )); +} + + +MPL_TEST_CASE() +{ + typedef vector2 v2; + + typedef begin::type i1; + typedef next::type i2; + typedef next::type i3; + + MPL_ASSERT(( is_same::type,char> )); + MPL_ASSERT(( is_same::type,long> )); + MPL_ASSERT(( is_same< i3, end::type > )); +} + +MPL_TEST_CASE() +{ + typedef vector0<> v0; + + typedef push_back::type v1; + typedef push_front::type v2; + typedef push_back::type v3; + + MPL_ASSERT(( is_same< back::type,int > )); + MPL_ASSERT(( is_same< back::type,int > )); + MPL_ASSERT(( is_same< front::type,char > )); + MPL_ASSERT(( is_same< back::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 v9; + + typedef pop_back::type v8; + typedef pop_front::type v7; + + MPL_ASSERT(( is_same< back::type,int > )); + MPL_ASSERT(( is_same< back::type,long > )); + MPL_ASSERT(( is_same< back::type,long > )); + MPL_ASSERT(( is_same< front::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 v1; + typedef vector v2; + typedef vector 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::value, ==, 0 ); + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 9 ); +} diff --git a/src/boost/libs/mpl/test/vector_c.cpp b/src/boost/libs/mpl/test/vector_c.cpp new file mode 100644 index 00000000..fbff9ea3 --- /dev/null +++ b/src/boost/libs/mpl/test/vector_c.cpp @@ -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 +#include +#include + +#include + +#if !BOOST_WORKAROUND(BOOST_MSVC, <=1200) +MPL_TEST_CASE() +{ + typedef vector_c::type v1; + typedef vector_c::type v2; + + MPL_ASSERT(( is_same< v1::value_type, bool > )); + MPL_ASSERT(( is_same< v2::value_type, bool > )); + + MPL_ASSERT_RELATION( front::type::value, ==, true ); + MPL_ASSERT_RELATION( front::type::value, ==, false ); +} +#endif + +MPL_TEST_CASE() +{ + typedef vector_c v1; + typedef vector_c v2; + typedef vector_c 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::value, ==, 1 ); + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_RELATION( size::value, ==, 3 ); + + MPL_ASSERT_RELATION( front::type::value, ==, -1 ); + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef vector_c v1; + typedef vector_c v2; + + MPL_ASSERT(( is_same< v1::value_type, unsigned > )); + MPL_ASSERT(( is_same< v2::value_type, unsigned > )); + + MPL_ASSERT_RELATION( size::type::value, ==, 1 ); + MPL_ASSERT_RELATION( size::type::value, ==, 2 ); + + MPL_ASSERT_RELATION( front::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front::type::value, ==, 1 ); +} diff --git a/src/boost/libs/mpl/test/zip_view.cpp b/src/boost/libs/mpl/test/zip_view.cpp new file mode 100644 index 00000000..a8d9b03c --- /dev/null +++ b/src/boost/libs/mpl/test/zip_view.cpp @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + + +MPL_TEST_CASE() +{ + typedef transform_view< + zip_view< vector< range_c, range_c > > + , unpack_args< plus<> > + > result; + + MPL_ASSERT(( equal< + result + , filter_view< range_c, is_even<_> > + , equal_to<_,_> + > )); + + MPL_ASSERT(( boost::is_same< zip_view >, zip_view >::type > )); +} -- cgit v1.2.3