From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/mpl/test/apply_wrap.cpp | 121 +++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/boost/libs/mpl/test/apply_wrap.cpp (limited to 'src/boost/libs/mpl/test/apply_wrap.cpp') 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 000000000..9c45f2e14 --- /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 +} -- cgit v1.2.3