Moved tests for core components to the sub-library.
This commit is contained in:
1 parent
82890fd03e
commit
07bff9e105
25 files changed
+44
-17
No files matched your search
+12
-17
@@ -1,5 +1,16 @@
|
||||
# Boost.MPL Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2005 Vladimir Prus
|
||||
# Copyright (c) 2006-2007 Dave Abrahams
|
||||
# Copyright (c) 2009 Eric Niebler
|
||||
# Copyright (c) 2009 Steven Watanabe
|
||||
#
|
||||
# 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
|
||||
|
||||
import testing ;
|
||||
|
||||
compile aux_/largest_int.cpp ;
|
||||
compile aux_/msvc_is_class.cpp ;
|
||||
compile aux_/template_arity.cpp ;
|
||||
compile aux_/preprocessor/is_seq.cpp ;
|
||||
@@ -9,15 +20,10 @@ compile advance.cpp ;
|
||||
compile always.cpp ;
|
||||
compile apply.cpp ;
|
||||
compile apply_wrap.cpp ;
|
||||
compile arithmetic.cpp ;
|
||||
compile as_sequence.cpp ;
|
||||
compile assert.cpp ;
|
||||
compile at.cpp ;
|
||||
compile back.cpp ;
|
||||
compile bind.cpp ;
|
||||
compile bitwise.cpp ;
|
||||
run bool.cpp ;
|
||||
compile comparison.cpp ;
|
||||
compile contains.cpp ;
|
||||
compile copy.cpp ;
|
||||
compile copy_if.cpp ;
|
||||
@@ -29,23 +35,16 @@ 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 has_xxx.cpp ;
|
||||
compile identity.cpp ;
|
||||
compile if.cpp ;
|
||||
compile index_of.cpp ;
|
||||
compile inherit.cpp ;
|
||||
compile insert.cpp ;
|
||||
compile insert_range.cpp ;
|
||||
run int.cpp ;
|
||||
run char.cpp ;
|
||||
run integral_c.cpp : : : <toolset>vacpp:<cxxflags>-qchars=signed ;
|
||||
compile is_placeholder.cpp ;
|
||||
compile is_sequence.cpp ;
|
||||
compile iterator_tags.cpp ;
|
||||
@@ -54,15 +53,12 @@ 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 ;
|
||||
@@ -80,7 +76,6 @@ 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 ;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef int_<0> _0;
|
||||
typedef int_<1> _1;
|
||||
typedef int_<3> _3;
|
||||
typedef int_<10> _10;
|
||||
|
||||
MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 );
|
||||
MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 );
|
||||
|
||||
MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 );
|
||||
MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 );
|
||||
|
||||
MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 );
|
||||
MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 );
|
||||
MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 );
|
||||
MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 );
|
||||
|
||||
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
|
||||
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
|
||||
|
||||
MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 );
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 );
|
||||
MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 );
|
||||
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
|
||||
#endif
|
||||
|
||||
MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 );
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
|
||||
|
||||
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
|
||||
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () );
|
||||
|
||||
namespace my {
|
||||
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
|
||||
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () );
|
||||
BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
struct her
|
||||
{
|
||||
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () );
|
||||
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
|
||||
BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) );
|
||||
#endif
|
||||
|
||||
void f()
|
||||
{
|
||||
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
#endif
|
||||
BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () );
|
||||
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
|
||||
BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct nested : boost::mpl::true_ {
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> ));
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
};
|
||||
|
||||
BOOST_MPL_ASSERT(( nested<int> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > ));
|
||||
|
||||
int main()
|
||||
{
|
||||
her<void> h;
|
||||
h.f();
|
||||
|
||||
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
|
||||
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () );
|
||||
BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/largest_int.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,bool>::type, bool > ));
|
||||
MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,char>::type, char > ));
|
||||
MPL_ASSERT(( is_same< mpl::aux::largest_int<char,bool>::type, char > ));
|
||||
MPL_ASSERT(( is_same< mpl::aux::largest_int<int,unsigned>::type, unsigned > ));
|
||||
MPL_ASSERT(( is_same< mpl::aux::largest_int<unsigned,long>::type, long > ));
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2003-2004
|
||||
// Copyright Jaap Suter 2003
|
||||
//
|
||||
// Distributed under the Boost Software License,Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/bitwise.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
typedef integral_c<unsigned int, 0> _0;
|
||||
typedef integral_c<unsigned int, 1> _1;
|
||||
typedef integral_c<unsigned int, 2> _2;
|
||||
typedef integral_c<unsigned int, 8> _8;
|
||||
typedef integral_c<unsigned int, 0xffffffff> _ffffffff;
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_RELATION( (bitand_<_0,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitand_<_1,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitand_<_0,_1>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitand_<_0,_ffffffff>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitand_<_1,_ffffffff>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (bitand_<_8,_ffffffff>::value), ==, 8 );
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_RELATION( (bitor_<_0,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitor_<_1,_0>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (bitor_<_0,_1>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff) );
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_RELATION( (bitxor_<_0,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (bitxor_<_1,_0>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (bitxor_<_0,_1>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 0) );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 1) );
|
||||
MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 8) );
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_RELATION( (shift_right<_0,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (shift_right<_1,_0>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (shift_right<_1,_1>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (shift_right<_2,_1>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (shift_right<_8,_1>::value), ==, 4 );
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_RELATION( (shift_left<_0,_0>::value), ==, 0 );
|
||||
MPL_ASSERT_RELATION( (shift_left<_1,_0>::value), ==, 1 );
|
||||
MPL_ASSERT_RELATION( (shift_left<_1,_1>::value), ==, 2 );
|
||||
MPL_ASSERT_RELATION( (shift_left<_2,_1>::value), ==, 4 );
|
||||
MPL_ASSERT_RELATION( (shift_left<_8,_1>::value), ==, 16 );
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License,Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
#define CONSTEXPR_BOOL_TEST(c)
|
||||
#else
|
||||
#define CONSTEXPR_BOOL_TEST(c) { static_assert(bool_<c>() == c, "Constexpr for bool_ failed"); }
|
||||
#endif
|
||||
|
||||
#define BOOL_TEST(c) \
|
||||
{ MPL_ASSERT(( is_same< bool_<c>::value_type, bool > )); } \
|
||||
{ MPL_ASSERT(( is_same< bool_<c>, c##_ > )); } \
|
||||
{ MPL_ASSERT(( is_same< bool_<c>::type, bool_<c> > )); } \
|
||||
{ MPL_ASSERT_RELATION( bool_<c>::value, ==, c ); } \
|
||||
CONSTEXPR_BOOL_TEST(c) \
|
||||
BOOST_TEST( bool_<c>() == c ); \
|
||||
/**/
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
BOOL_TEST(true)
|
||||
BOOL_TEST(false)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
// Copyright Eric Niebler 2008
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id: char.cpp 49240 2009-04-01 09:21:07Z eric_niebler $
|
||||
// $Date: 2009-04-01 02:21:07 -0700 (Wed, 1 Apr 2009) $
|
||||
// $Revision: 49240 $
|
||||
|
||||
#include <boost/mpl/char.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
#include "integral_wrapper_test.hpp"
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
# define WRAPPER(T, i) char_<i>
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char)
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/comparison.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
// make sure MSVC behaves nicely in presence of the following template
|
||||
template< typename T > struct value {};
|
||||
|
||||
typedef int_<0> _0;
|
||||
typedef int_<10> _10;
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_NOT(( equal_to<_0, _10> ));
|
||||
MPL_ASSERT_NOT(( equal_to<_10, _0> ));
|
||||
MPL_ASSERT(( equal_to<_10, _10> ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( not_equal_to<_0, _10> ));
|
||||
MPL_ASSERT(( not_equal_to<_10, _0> ));
|
||||
MPL_ASSERT_NOT(( not_equal_to<_10, _10> ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( less<_0, _10> ));
|
||||
MPL_ASSERT_NOT(( less<_10, _0> ));
|
||||
MPL_ASSERT_NOT(( less<_10, _10> ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( less_equal<_0, _10> ));
|
||||
MPL_ASSERT_NOT(( less_equal<_10, _0> ));
|
||||
MPL_ASSERT(( less_equal<_10, _10> ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( greater<_10, _0> ));
|
||||
MPL_ASSERT_NOT(( greater<_0, _10> ));
|
||||
MPL_ASSERT_NOT(( greater<_10, _10> ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_NOT(( greater_equal<_0, _10> ));
|
||||
MPL_ASSERT(( greater_equal<_10, _0> ));
|
||||
MPL_ASSERT(( greater_equal<_10, _10> ));
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef eval_if< true_, identity<char>, identity<long> >::type t1;
|
||||
typedef eval_if_c< true, identity<char>, identity<long> >::type t2;
|
||||
typedef eval_if< false_, identity<char>, identity<long> >::type t3;
|
||||
typedef eval_if_c< false, identity<char>, identity<long> >::type t4;
|
||||
|
||||
MPL_ASSERT(( is_same<t1,char> ));
|
||||
MPL_ASSERT(( is_same<t2,char> ));
|
||||
MPL_ASSERT(( is_same<t3,long> ));
|
||||
MPL_ASSERT(( is_same<t4,long> ));
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Daniel Walker 2007
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(has_xxx_template, xxx, false)
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(yyy)
|
||||
|
||||
struct a1 {};
|
||||
struct a2 { void xxx(); };
|
||||
struct a3 { int xxx; };
|
||||
struct a4 { static int xxx(); };
|
||||
struct a5 { template< typename T > struct xxx {}; };
|
||||
|
||||
struct b1 { typedef int xxx; };
|
||||
struct b2 { struct xxx; };
|
||||
struct b3 { typedef int& xxx; };
|
||||
struct b4 { typedef int* xxx; };
|
||||
struct b5 { typedef int xxx[10]; };
|
||||
struct b6 { typedef void (*xxx)(); };
|
||||
struct b7 { typedef void (xxx)(); };
|
||||
|
||||
struct c1 { template< typename T > struct xxx {}; };
|
||||
struct c2 { template< typename T1, typename T2 > struct xxx {}; };
|
||||
struct c3 { template< typename T1, typename T2, typename T3 > struct xxx {}; };
|
||||
struct c4 { template< typename T1, typename T2, typename T3, typename T4 > struct xxx {}; };
|
||||
struct c5 { template< typename T1, typename T2, typename T3, typename T4, typename T5 > struct xxx {}; };
|
||||
struct c6 { template< typename T > struct yyy {}; };
|
||||
struct c7 { template< typename T1, typename T2 > struct yyy {}; };
|
||||
|
||||
template< typename T > struct outer;
|
||||
template< typename T > struct inner { typedef typename T::type type; };
|
||||
|
||||
// agurt, 15/aug/04: make sure MWCW passes the test in presence of the following
|
||||
// template
|
||||
template< typename T > struct xxx;
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_NOT(( has_xxx<int> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int> ));
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
MPL_ASSERT_NOT(( has_xxx<int&> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int&> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int*> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int*> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int[]> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int[]> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int (*)()> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int (*)()> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a2> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a2> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a3> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a3> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a4> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a4> ));
|
||||
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
|
||||
MPL_ASSERT_NOT(( has_xxx<a5> ));
|
||||
MPL_ASSERT(( has_xxx_template<a5> ));
|
||||
#endif
|
||||
MPL_ASSERT_NOT(( has_xxx< enum_ > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< enum_ > ));
|
||||
#endif
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a1> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a1> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< outer< inner<int> > > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< incomplete > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< incomplete > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< abstract > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< abstract > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< noncopyable > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< noncopyable > ));
|
||||
|
||||
#if !BOOST_WORKAROUND(__COMO_VERSION__, BOOST_TESTED_AT(4308))
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b1> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b2> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b3> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b4> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b5> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b6> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b7> ));
|
||||
#endif
|
||||
|
||||
// Same name, different args.
|
||||
MPL_ASSERT(( has_xxx_template<c1> ));
|
||||
MPL_ASSERT(( has_xxx_template<c2> ));
|
||||
MPL_ASSERT(( has_xxx_template<c3> ));
|
||||
MPL_ASSERT(( has_xxx_template<c4> ));
|
||||
MPL_ASSERT(( has_xxx_template<c5> ));
|
||||
MPL_ASSERT(( has_yyy<c6> ));
|
||||
MPL_ASSERT(( has_yyy<c7> ));
|
||||
|
||||
// Different name, different args.
|
||||
MPL_ASSERT_NOT(( has_xxx_template<c6> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<c7> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c1> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c2> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c3> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c4> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c5> ));
|
||||
|
||||
MPL_ASSERT(( has_xxx<b1,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b2,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b3,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b4,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b5,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b6,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b7,true_> ));
|
||||
|
||||
MPL_ASSERT(( has_xxx_template<c1,true_> ));
|
||||
|
||||
#if !defined(HAS_XXX_ASSERT)
|
||||
# define HAS_XXX_ASSERT(x) MPL_ASSERT(x)
|
||||
#endif
|
||||
|
||||
HAS_XXX_ASSERT(( has_xxx<b1> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b2> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b3> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b4> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b5> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b6> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b7> ));
|
||||
|
||||
#if !defined(HAS_XXX_TEMPLATE_ASSERT)
|
||||
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT(x)
|
||||
#endif
|
||||
|
||||
HAS_XXX_TEMPLATE_ASSERT(( has_xxx_template<c1> ));
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License,Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef apply1< identity<>, char >::type t1;
|
||||
typedef apply1< identity<_1>, int >::type t2;
|
||||
MPL_ASSERT(( is_same< t1, char > ));
|
||||
MPL_ASSERT(( is_same< t2, int > ));
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef apply1< make_identity<>, char >::type t1;
|
||||
typedef apply1< make_identity<_1>, int >::type t2;
|
||||
MPL_ASSERT(( is_same< t1, identity<char> > ));
|
||||
MPL_ASSERT(( is_same< t2, identity<int> > ));
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License,Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef if_<true_,char,long>::type t1;
|
||||
typedef if_c<true,char,long>::type t2;
|
||||
typedef if_<false_,char,long>::type t3;
|
||||
typedef if_c<false,char,long>::type t4;
|
||||
|
||||
MPL_ASSERT(( is_same<t1, char> ));
|
||||
MPL_ASSERT(( is_same<t2, char> ));
|
||||
MPL_ASSERT(( is_same<t3, long> ));
|
||||
MPL_ASSERT(( is_same<t4, long> ));
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
#include "integral_wrapper_test.hpp"
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
# define WRAPPER(T, i) int_<i>
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License,Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
#include "integral_wrapper_test.hpp"
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
# define WRAPPER(T, i) integral_c<T,i>
|
||||
|
||||
#if !(defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3))
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char)
|
||||
#endif
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, short)
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
|
||||
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, long)
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2006
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/next_prior.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
||||
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
|
||||
BOOST_TEST(( WRAPPER(T,i)() == i )); \
|
||||
BOOST_TEST(( WRAPPER(T,i)::value == i )); \
|
||||
/**/
|
||||
#else
|
||||
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
|
||||
BOOST_TEST(( WRAPPER(T,i)::value == i )); \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
#define CONSTEXPR_INTEGRAL_TEST(T, i)
|
||||
#else
|
||||
#define CONSTEXPR_INTEGRAL_TEST(T, i) { static_assert(T() == i, "Constexpr for integral constant failed"); }
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
// agurt 20/nov/06: see http://article.gmane.org/gmane.comp.lib.boost.devel/151065
|
||||
#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
|
||||
{ \
|
||||
typedef WRAPPER(T,i) borland_tested_type; \
|
||||
{ typedef is_same< borland_tested_type::value_type, T > borland_test_type; \
|
||||
MPL_ASSERT(( borland_test_type )); } \
|
||||
{ MPL_ASSERT(( is_same< borland_tested_type::type, WRAPPER(T,i) > )); } \
|
||||
{ MPL_ASSERT(( is_same< next< borland_tested_type >::type, WRAPPER(T,i+1) > )); } \
|
||||
{ MPL_ASSERT(( is_same< prior< borland_tested_type >::type, WRAPPER(T,i-1) > )); } \
|
||||
{ MPL_ASSERT_RELATION( (borland_tested_type::value), ==, i ); } \
|
||||
CONSTEXPR_INTEGRAL_TEST(borland_tested_type, i) \
|
||||
INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
|
||||
} \
|
||||
/**/
|
||||
#else
|
||||
#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
|
||||
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::value_type, T > )); } \
|
||||
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::type, WRAPPER(T,i) > )); } \
|
||||
{ MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \
|
||||
{ MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \
|
||||
{ MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \
|
||||
CONSTEXPR_INTEGRAL_TEST(WRAPPER(T,i), i) \
|
||||
INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/logical.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
struct unknown;
|
||||
|
||||
using mpl::true_;
|
||||
using mpl::false_;
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( mpl::and_< true_,true_ > ));
|
||||
MPL_ASSERT_NOT(( mpl::and_< false_,true_ > ));
|
||||
MPL_ASSERT_NOT(( mpl::and_< true_,false_ > ));
|
||||
MPL_ASSERT_NOT(( mpl::and_< false_,false_ > ));
|
||||
MPL_ASSERT_NOT(( mpl::and_< false_,unknown > ));
|
||||
MPL_ASSERT_NOT(( mpl::and_< false_,unknown,unknown > ));
|
||||
|
||||
MPL_ASSERT(( mpl::or_< true_,true_ > ));
|
||||
MPL_ASSERT(( mpl::or_< false_,true_ > ));
|
||||
MPL_ASSERT(( mpl::or_< true_,false_ > ));
|
||||
MPL_ASSERT_NOT(( mpl::or_< false_,false_ > ));
|
||||
MPL_ASSERT(( mpl::or_< true_,unknown > ));
|
||||
MPL_ASSERT(( mpl::or_< true_,unknown,unknown > ));
|
||||
|
||||
MPL_ASSERT_NOT(( mpl::not_< true_ > ));
|
||||
MPL_ASSERT(( mpl::not_< false_ > ));
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright David Abrahams 2003
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
|
||||
// This file tests that we have the right value for
|
||||
// BOOST_MPL_CFG_NO_HAS_XXX, and that 'has_xxx' doesn't just fail to
|
||||
// compile arbitrarily.
|
||||
|
||||
#include <boost/mpl/aux_/config/has_xxx.hpp>
|
||||
|
||||
#if defined(BOOST_MPL_CFG_NO_HAS_XXX)
|
||||
# define HAS_XXX_ASSERT(x) MPL_ASSERT_NOT(x)
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
|
||||
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT_NOT(x)
|
||||
#endif
|
||||
|
||||
#include "has_xxx.cpp"
|
||||
@@ -1,155 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2003-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
#include <boost/mpl/comparison.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/long.hpp>
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
struct complex_tag : int_<10> {};
|
||||
|
||||
template< typename Re, typename Im > struct complex
|
||||
{
|
||||
typedef complex_tag tag;
|
||||
typedef complex type;
|
||||
typedef Re real;
|
||||
typedef Im imag;
|
||||
};
|
||||
|
||||
template< typename C > struct real : C::real {};
|
||||
template< typename C > struct imag : C::imag {};
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<> struct BOOST_MPL_AUX_NUMERIC_CAST< integral_c_tag,complex_tag >
|
||||
{
|
||||
template< typename N > struct apply
|
||||
: complex< N, integral_c< typename N::value_type, 0 > >
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct plus_impl< complex_tag,complex_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
: complex<
|
||||
plus< typename N1::real, typename N2::real >
|
||||
, plus< typename N1::imag, typename N2::imag >
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl< complex_tag,complex_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
: complex<
|
||||
minus<
|
||||
times< typename N1::real, typename N2::real >
|
||||
, times< typename N1::imag, typename N2::imag >
|
||||
>
|
||||
, plus<
|
||||
times< typename N1::real, typename N2::imag >
|
||||
, times< typename N1::imag, typename N2::real >
|
||||
>
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct equal_to_impl< complex_tag,complex_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
: and_<
|
||||
equal_to< typename N1::real, typename N2::real >
|
||||
, equal_to< typename N1::imag, typename N2::imag >
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
typedef int_<2> i;
|
||||
typedef complex< int_<5>, int_<-1> > c1;
|
||||
typedef complex< int_<-5>, int_<1> > c2;
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef plus<c1,c2>::type r1;
|
||||
MPL_ASSERT_RELATION( real<r1>::value, ==, 0 );
|
||||
MPL_ASSERT_RELATION( imag<r1>::value, ==, 0 );
|
||||
|
||||
typedef plus<c1,c1>::type r2;
|
||||
MPL_ASSERT_RELATION( real<r2>::value, ==, 10 );
|
||||
MPL_ASSERT_RELATION( imag<r2>::value, ==, -2 );
|
||||
|
||||
typedef plus<c2,c2>::type r3;
|
||||
MPL_ASSERT_RELATION( real<r3>::value, ==, -10 );
|
||||
MPL_ASSERT_RELATION( imag<r3>::value, ==, 2 );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
typedef plus<c1,i>::type r4;
|
||||
MPL_ASSERT_RELATION( real<r4>::value, ==, 7 );
|
||||
MPL_ASSERT_RELATION( imag<r4>::value, ==, -1 );
|
||||
|
||||
typedef plus<i,c2>::type r5;
|
||||
MPL_ASSERT_RELATION( real<r5>::value, ==, -3 );
|
||||
MPL_ASSERT_RELATION( imag<r5>::value, ==, 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef times<c1,c2>::type r1;
|
||||
MPL_ASSERT_RELATION( real<r1>::value, ==, -24 );
|
||||
MPL_ASSERT_RELATION( imag<r1>::value, ==, 10 );
|
||||
|
||||
typedef times<c1,c1>::type r2;
|
||||
MPL_ASSERT_RELATION( real<r2>::value, ==, 24 );
|
||||
MPL_ASSERT_RELATION( imag<r2>::value, ==, -10 );
|
||||
|
||||
typedef times<c2,c2>::type r3;
|
||||
MPL_ASSERT_RELATION( real<r3>::value, ==, 24 );
|
||||
MPL_ASSERT_RELATION( imag<r3>::value, ==, -10 );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
typedef times<c1,i>::type r4;
|
||||
MPL_ASSERT_RELATION( real<r4>::value, ==, 10 );
|
||||
MPL_ASSERT_RELATION( imag<r4>::value, ==, -2 );
|
||||
|
||||
typedef times<i,c2>::type r5;
|
||||
MPL_ASSERT_RELATION( real<r5>::value, ==, -10 );
|
||||
MPL_ASSERT_RELATION( imag<r5>::value, ==, 2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT(( equal_to<c1,c1> ));
|
||||
MPL_ASSERT(( equal_to<c2,c2> ));
|
||||
MPL_ASSERT_NOT(( equal_to<c1,c2> ));
|
||||
|
||||
MPL_ASSERT(( equal_to<c1, complex< long_<5>, long_<-1> > > ));
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
MPL_ASSERT_NOT(( equal_to<c1,i> ));
|
||||
MPL_ASSERT_NOT(( equal_to<i,c2> ));
|
||||
#endif
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/print.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef print<int>::type t;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
// Necessary to overcome a strange name lookup bug in GCC 3.3 and 4.0 for Mac OS X
|
||||
#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ <= 4)
|
||||
# include <cassert>
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
|
||||
#include "integral_wrapper_test.hpp"
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
# define WRAPPER(T, i) mpl::size_t<i>
|
||||
BOOST_PP_REPEAT_FROM_TO(1, 11, INTEGRAL_WRAPPER_TEST, std::size_t)
|
||||
}
|
||||
Reference in new issue
Block a user