mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-19 04:22:11 +00:00
* It normally should not be necessary to use the _Z form of the BOOST_PP_ENUM macro, although it is perfectly legal and helpful to do so, but in this case it is necessary as a workaround for a bug in the new VC++ standard conforming preprocessor. The bug manifests itself when testing the TTI library, which internally uses the Boost MPL code. The bug in the new VC++ standard conforming compiler is fixed in the VS2019 preview product, so that fix is sure to find its way to the official VS2019 product sometime soon. In the meantime this "fix" shortens the macro expansion somewhat and, while it should not be necessary, is still helpful. * Fix for appveyor.yml file * Added VS2019 tests, also with new preprocessor. Further MPL Fixes for new preprocessor bug, which are also useful and will speed up preprocessing. * Can't seem to test msvc-10.0 or msvc-11.0 any more with Appveyor * Update description
122 lines
2.8 KiB
C++
122 lines
2.8 KiB
C++
|
|
// Copyright Aleksey Gurtovoy 2000-2004
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
// See http://www.boost.org/libs/mpl for documentation.
|
|
|
|
// $Id$
|
|
// $Date$
|
|
// $Revision$
|
|
|
|
#include <boost/mpl/apply_wrap.hpp>
|
|
#include <boost/mpl/limits/arity.hpp>
|
|
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
|
#include <boost/mpl/aux_/preprocessor/enum.hpp>
|
|
#include <boost/mpl/aux_/test.hpp>
|
|
|
|
#include <boost/preprocessor/repeat.hpp>
|
|
#include <boost/preprocessor/comma_if.hpp>
|
|
#include <boost/preprocessor/dec.hpp>
|
|
#include <boost/preprocessor/if.hpp>
|
|
#include <boost/preprocessor/cat.hpp>
|
|
|
|
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
|
|
# define APPLY_0_FUNC_DEF(z_ignored,i) \
|
|
struct f0 \
|
|
{ \
|
|
template< typename T = int > struct apply { typedef char type; }; \
|
|
}; \
|
|
/**/
|
|
#else
|
|
# define APPLY_0_FUNC_DEF(z_ignored,i) \
|
|
struct f0 \
|
|
{ \
|
|
template< typename T > struct apply { typedef char type; }; \
|
|
}; \
|
|
/**/
|
|
#endif
|
|
|
|
#define APPLY_N_FUNC_DEF(z,i) \
|
|
struct first##i \
|
|
{ \
|
|
template< BOOST_MPL_PP_PARAMS_Z(z, i, typename U) > \
|
|
struct apply { typedef U1 type; }; \
|
|
}; \
|
|
\
|
|
struct last##i \
|
|
{ \
|
|
template< BOOST_MPL_PP_PARAMS_Z(z, 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 \
|
|
)(z,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(z_ignored, i, apply_) \
|
|
typedef apply_<test::f##i>::type t; \
|
|
{ MPL_ASSERT(( boost::is_same<t, char> )); } \
|
|
/**/
|
|
|
|
#define APPLY_N_TEST(z, i, apply_) \
|
|
typedef apply_< \
|
|
test::first##i \
|
|
, char \
|
|
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
|
|
BOOST_MPL_PP_ENUM_Z(z, BOOST_PP_DEC(i), int) \
|
|
>::type t1##i; \
|
|
\
|
|
typedef apply_< \
|
|
test::last##i \
|
|
, BOOST_MPL_PP_ENUM_Z(z, BOOST_PP_DEC(i), int) \
|
|
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
|
|
>::type t2##i; \
|
|
{ MPL_ASSERT(( boost::is_same<t1##i, char> )); } \
|
|
{ MPL_ASSERT(( boost::is_same<t2##i, char> )); } \
|
|
/**/
|
|
|
|
#define APPLY_TEST(z, i, unused) \
|
|
BOOST_PP_IF( \
|
|
i \
|
|
, APPLY_N_TEST \
|
|
, APPLY_0_TEST \
|
|
)(z, i, BOOST_PP_CAT(apply_wrap,i)) \
|
|
/**/
|
|
|
|
|
|
MPL_TEST_CASE()
|
|
{
|
|
BOOST_PP_REPEAT(
|
|
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
|
|
, APPLY_TEST
|
|
, unused
|
|
)
|
|
|
|
#if !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
|
|
{
|
|
typedef apply_wrap0<test::g0>::type t;
|
|
MPL_ASSERT(( boost::is_same<t, char> ));
|
|
}
|
|
#endif
|
|
}
|