mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-02 22:34:31 +02:00
Initial re-commit after CVS disk crash
[SVN r18349]
This commit is contained in:
82
include/boost/mpl/aux_/test/assert.hpp
Normal file
82
include/boost/mpl/aux_/test/assert.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_TEST_ASSERT_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_TEST_ASSERT_HPP_INCLUDED
|
||||
|
||||
// + file: boost/mpl/aux_/test/assert.hpp
|
||||
// + last modified: 04/may/03
|
||||
|
||||
// Copyright (c) 2002-03
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/aux_/config/ctps.hpp"
|
||||
#include "boost/mpl/aux_/config/msvc.hpp"
|
||||
#include "boost/mpl/aux_/config/workaround.hpp"
|
||||
|
||||
#include "boost/static_assert.hpp"
|
||||
|
||||
#include "boost/preprocessor/tuple/rem.hpp"
|
||||
#include "boost/preprocessor/control/expr_if.hpp"
|
||||
#include "boost/preprocessor/logical/not.hpp"
|
||||
|
||||
#define CTT_assert( expr ) BOOST_STATIC_ASSERT( expr )
|
||||
#define CTT_assert_equal(arity, tuple) assert_equal< BOOST_PP_TUPLE_REM(arity)tuple >::type()
|
||||
#define CTT_assert_not_equal(arity, tuple) assert_not_equal< BOOST_PP_TUPLE_REM(arity)tuple >()
|
||||
#define CTT_assert_same(arity, tuple) assert_same< BOOST_PP_TUPLE_REM(arity)tuple >()
|
||||
#define CTT_assert_not_same(arity, tuple) assert_not_same< BOOST_PP_TUPLE_REM(arity)tuple >()
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
# define AUX_ASSERT_DEF( param_type, suffix, test_equality ) \
|
||||
template< param_type x, param_type y > struct assert_##suffix \
|
||||
BOOST_PP_EXPR_IF( BOOST_PP_NOT(test_equality), {} ); \
|
||||
template< param_type x > struct assert_##suffix<x,x> \
|
||||
BOOST_PP_EXPR_IF( test_equality, {} ); \
|
||||
/**/
|
||||
#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
# define AUX_ASSERT_DEF( param_type, suffix, test_equality ) \
|
||||
template< param_type x > struct assert_##suffix##_impl \
|
||||
{ \
|
||||
template< param_type y > struct result_; \
|
||||
template<> struct result_<x> \
|
||||
{ BOOST_PP_EXPR_IF( BOOST_PP_NOT(test_equality), private: virtual ~result_<x>() = 0; ) }; \
|
||||
template< param_type y > struct result_ \
|
||||
{ BOOST_PP_EXPR_IF( test_equality, private: virtual ~result_<y>() = 0; ) }; \
|
||||
}; \
|
||||
\
|
||||
template< param_type x, param_type y > struct assert_##suffix \
|
||||
: assert_##suffix##_impl<x>::template result_<y> {}; \
|
||||
/**/
|
||||
#else
|
||||
# define AUX_ASSERT_DEF( param_type, suffix, test_equality ) \
|
||||
template< param_type x > struct assert_##suffix##_impl \
|
||||
{ \
|
||||
template< param_type y > struct result_ \
|
||||
BOOST_PP_EXPR_IF( BOOST_PP_NOT(test_equality), {} ); \
|
||||
}; \
|
||||
template< param_type x > struct assert_##suffix##_impl<x>::result_<x> \
|
||||
BOOST_PP_EXPR_IF( test_equality, {} ); \
|
||||
\
|
||||
template< param_type x, param_type y > struct assert_##suffix \
|
||||
: assert_##suffix##_impl<x>::template result_<y> {}; \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
AUX_ASSERT_DEF(long, equal, 1)
|
||||
AUX_ASSERT_DEF(long, not_equal, 0)
|
||||
AUX_ASSERT_DEF(typename, same, 1)
|
||||
AUX_ASSERT_DEF(typename, not_same, 0)
|
||||
}
|
||||
|
||||
#undef AUX_ASSERT_DEF
|
||||
|
||||
#endif // BOOST_MPL_AUX_TEST_ASSERT_HPP_INCLUDED
|
44
include/boost/mpl/aux_/test/data.hpp
Normal file
44
include/boost/mpl/aux_/test/data.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_TEST_DATA_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_TEST_DATA_HPP_INCLUDED
|
||||
|
||||
// + file: boost/mpl/aux_/test/data.hpp
|
||||
// + last modified: 04/may/03
|
||||
|
||||
// Copyright (c) 2002-03
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/noncopyable.hpp"
|
||||
|
||||
struct UDT {};
|
||||
struct incomplete;
|
||||
class abstract { virtual ~abstract() = 0; };
|
||||
using boost::noncopyable;
|
||||
|
||||
// to do: add function types for compilers that are able to handle them
|
||||
// (T ())(T (int))(void (T))(T (T))
|
||||
// (T[10])(T const[10])(T volatile[10])(T const volatile[10])
|
||||
// (T (*)())(T (* const)())(T (* volatile)())(T (* const volatile)())
|
||||
// (T (*)(int))(void (*)(T))(T (*)(T))
|
||||
|
||||
#define CTT_basic_modifiers( T ) \
|
||||
(T const)(T volatile)(T const volatile) \
|
||||
(T&)(T const&)(T volatile&)(T const volatile&) \
|
||||
(T*)(T const*)(T volatile*)(T const volatile*) \
|
||||
/**/
|
||||
|
||||
#define CTT_basic_types() \
|
||||
(bool)(char)(int)(UDT)(incomplete)(noncopyable)(abstract) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_TEST_DATA_HPP_INCLUDED
|
60
include/boost/mpl/aux_/test/for_each.hpp
Normal file
60
include/boost/mpl/aux_/test/for_each.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_TEST_FOR_EACH_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_TEST_FOR_EACH_HPP_INCLUDED
|
||||
|
||||
// + file: boost/mpl/aux_/test/for_each.hpp
|
||||
// + last modified: 04/may/03
|
||||
|
||||
// Copyright (c) 2002-03
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/aux_/preprocessor/is_seq.hpp"
|
||||
|
||||
#include "boost/preprocessor/seq/for_each_i.hpp"
|
||||
#include "boost/preprocessor/seq/transform.hpp"
|
||||
#include "boost/preprocessor/seq/enum.hpp"
|
||||
#include "boost/preprocessor/tuple/elem.hpp"
|
||||
#include "boost/preprocessor/control/expr_if.hpp"
|
||||
#include "boost/preprocessor/cat.hpp"
|
||||
|
||||
#define CTT_AUX_IS_PLACEHOLDER_1 (1)
|
||||
|
||||
#define CTT_AUX_IS_PLACEHOLDER(x) \
|
||||
BOOST_MPL_PP_IS_SEQ( BOOST_PP_CAT(CTT_AUX_IS_PLACEHOLDER, x) ) \
|
||||
/**/
|
||||
|
||||
#define CTT_AUX_PARAM_OR_T( unused, T, param ) \
|
||||
BOOST_PP_TUPLE_ELEM( 2, CTT_AUX_IS_PLACEHOLDER(param), (param, T) ) \
|
||||
/**/
|
||||
|
||||
#define CTT_AUX_REPLACE_PLACEHOLDER( params_seq, T ) \
|
||||
BOOST_PP_SEQ_ENUM( \
|
||||
BOOST_PP_SEQ_TRANSFORM( CTT_AUX_PARAM_OR_T, T, params_seq ) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#define CTT_AUX_INVOKE_TEST( unused, test_params_pair, i, T ) \
|
||||
BOOST_PP_EXPR_IF(i, ;) \
|
||||
BOOST_PP_TUPLE_ELEM(2, 0, test_params_pair)< \
|
||||
CTT_AUX_REPLACE_PLACEHOLDER( \
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, test_params_pair) \
|
||||
, T \
|
||||
) \
|
||||
>() \
|
||||
/**/
|
||||
|
||||
#define CTT_for_each( seq, test, params_seq ) \
|
||||
BOOST_PP_SEQ_FOR_EACH_I( CTT_AUX_INVOKE_TEST, (test, params_seq), seq ) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_TEST_FOR_EACH_HPP_INCLUDED
|
40
include/boost/mpl/aux_/test/test_case.hpp
Normal file
40
include/boost/mpl/aux_/test/test_case.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_TEST_TEST_CASE_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_TEST_TEST_CASE_HPP_INCLUDED
|
||||
|
||||
// + file: boost/mpl/aux_/test/test_case.hpp
|
||||
// + last modified: 04/may/03
|
||||
|
||||
// Copyright (c) 2002-03
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/preprocessor/comma_if.hpp"
|
||||
#include "boost/preprocessor/seq/for_each_i.hpp"
|
||||
#include "boost/preprocessor/seq/enum.hpp"
|
||||
|
||||
#define CTT_AUX_PARAM_DEF(unused, prefix, i, elem) \
|
||||
BOOST_PP_COMMA_IF(i) prefix elem \
|
||||
/**/
|
||||
|
||||
#define CTT_test_case( name, params_seq ) \
|
||||
template< \
|
||||
BOOST_PP_SEQ_FOR_EACH_I( CTT_AUX_PARAM_DEF, typename, params_seq ) \
|
||||
> \
|
||||
void name() \
|
||||
/**/
|
||||
|
||||
#define CTT_test( test, params_seq ) \
|
||||
test< BOOST_PP_SEQ_ENUM(params_seq) >() \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_TEST_TEST_CASE_HPP_INCLUDED
|
42
test/aux_/preprocessor/is_seq.cpp
Normal file
42
test/aux_/preprocessor/is_seq.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
// + file: libs/mpl/test/aux_/is_seq.cpp
|
||||
// + last modified: 03/may/03
|
||||
|
||||
// Copyright (c) 2003
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/aux_/preprocessor/is_seq.hpp"
|
||||
|
||||
#include "boost/preprocessor/logical/not.hpp"
|
||||
#include "boost/preprocessor/debug/assert.hpp"
|
||||
|
||||
#define AUX_ASSERT_IS_SEQ( seq ) \
|
||||
BOOST_PP_ASSERT( BOOST_MPL_PP_IS_SEQ(seq) ) \
|
||||
/**/
|
||||
|
||||
#define AUX_ASSERT_IS_NOT_SEQ( seq ) \
|
||||
BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_IS_SEQ(seq) ) ) \
|
||||
/**/
|
||||
|
||||
#define SEQ (a)(b)(c)
|
||||
|
||||
int main()
|
||||
{
|
||||
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 )
|
||||
|
||||
return 0;
|
||||
}
|
45
test/aux_/preprocessor/token_equal.cpp
Normal file
45
test/aux_/preprocessor/token_equal.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
// + file: libs/mpl/test/aux_/token_eqaul.cpp
|
||||
// + last modified: 03/may/03
|
||||
|
||||
// Copyright (c) 2003
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/aux_/preprocessor/token_equal.hpp"
|
||||
|
||||
#include "boost/preprocessor/logical/not.hpp"
|
||||
#include "boost/preprocessor/debug/assert.hpp"
|
||||
|
||||
#define AUX_ASSERT_EQUAL(x, y) \
|
||||
BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) \
|
||||
/**/
|
||||
|
||||
#define AUX_ASSERT_NOT_EQUAL(x, y) \
|
||||
BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) ) \
|
||||
/**/
|
||||
|
||||
int main()
|
||||
{
|
||||
#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 )
|
||||
|
||||
return 0;
|
||||
}
|
42
test/aux_/test/test_case.cpp
Normal file
42
test/aux_/test/test_case.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
// + file: libs/mpl/aux_/test/test_case.cpp
|
||||
// + last modified: 03/may/03
|
||||
|
||||
// Copyright (c) 2002-03
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/aux_/test.hpp"
|
||||
|
||||
CTT_test_case( false_positives, (S)(T) )
|
||||
{
|
||||
CTT_assert_same( 2, (S, char) );
|
||||
CTT_assert_not_same( 2, (S, bool) );
|
||||
//T t;
|
||||
}
|
||||
|
||||
CTT_test_case( empty_set, (T) )
|
||||
{
|
||||
CTT_for_each(
|
||||
(T)(T const)
|
||||
, false_positives
|
||||
, (char)(_1)
|
||||
);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
CTT_test( empty_set, (bool) );
|
||||
CTT_for_each( (int)(long), empty_set, (_1) );
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user