Files
boost_mpl/include/boost/mpl/aux_/count_args.hpp
T

105 lines
2.9 KiB
C++
Raw Normal View History

2004-09-02 15:41:37 +00:00
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
// Copyright Aleksey Gurtovoy 2000-2004
2002-09-15 22:13:24 +00:00
//
2004-09-02 15:41:37 +00:00
// 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)
2004-09-02 15:41:37 +00:00
//
// See http://www.boost.org/libs/mpl for documentation.
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
// $Source$
// $Date$
// $Revision$
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#include <boost/preprocessor/expr_if.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/cat.hpp>
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#if !defined(AUX778076_COUNT_ARGS_PARAM_NAME)
# define AUX778076_COUNT_ARGS_PARAM_NAME T
#endif
#if !defined(AUX778076_COUNT_ARGS_TEMPLATE_PARAM)
# define AUX778076_COUNT_ARGS_TEMPLATE_PARAM typename AUX778076_COUNT_ARGS_PARAM_NAME
2002-09-15 22:13:24 +00:00
#endif
// local macros, #undef-ined at the end of the header
2004-09-02 15:41:37 +00:00
#if !defined(AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES)
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
# include <boost/mpl/aux_/preprocessor/repeat.hpp>
# include <boost/mpl/aux_/preprocessor/params.hpp>
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
# define AUX778076_COUNT_ARGS_REPEAT BOOST_MPL_PP_REPEAT
# define AUX778076_COUNT_ARGS_PARAMS(param) \
2002-09-15 22:13:24 +00:00
BOOST_MPL_PP_PARAMS( \
2004-09-02 15:41:37 +00:00
AUX778076_COUNT_ARGS_ARITY \
2002-09-15 22:13:24 +00:00
, param \
) \
/**/
#else
2004-09-02 15:41:37 +00:00
# include <boost/preprocessor/enum_shifted_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/inc.hpp>
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
# define AUX778076_COUNT_ARGS_REPEAT BOOST_PP_REPEAT
# define AUX778076_COUNT_ARGS_PARAMS(param) \
2002-09-15 22:13:24 +00:00
BOOST_PP_ENUM_SHIFTED_PARAMS( \
2004-09-02 15:41:37 +00:00
BOOST_PP_INC(AUX778076_COUNT_ARGS_ARITY) \
2002-09-15 22:13:24 +00:00
, param \
) \
/**/
2004-09-02 15:41:37 +00:00
#endif // AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#define AUX778076_IS_ARG_TEMPLATE_NAME \
BOOST_PP_CAT(is_,BOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_arg)) \
2002-09-15 22:13:24 +00:00
/**/
2004-09-02 15:41:37 +00:00
#define AUX778076_COUNT_ARGS_FUNC(unused, i, param) \
2002-09-15 22:13:24 +00:00
BOOST_PP_EXPR_IF(i, +) \
2004-09-02 15:41:37 +00:00
AUX778076_IS_ARG_TEMPLATE_NAME<BOOST_PP_CAT(param,BOOST_PP_INC(i))>::value \
2002-09-15 22:13:24 +00:00
/**/
// is_<xxx>_arg
2004-09-02 15:41:37 +00:00
template< AUX778076_COUNT_ARGS_TEMPLATE_PARAM >
struct AUX778076_IS_ARG_TEMPLATE_NAME
2002-09-15 22:13:24 +00:00
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
2004-09-02 15:41:37 +00:00
struct AUX778076_IS_ARG_TEMPLATE_NAME<AUX778076_COUNT_ARGS_DEFAULT>
2002-09-15 22:13:24 +00:00
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
// <xxx>_count_args
template<
2004-09-02 15:41:37 +00:00
AUX778076_COUNT_ARGS_PARAMS(AUX778076_COUNT_ARGS_TEMPLATE_PARAM)
2002-09-15 22:13:24 +00:00
>
2004-09-02 15:41:37 +00:00
struct BOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_count_args)
2002-09-15 22:13:24 +00:00
{
2004-09-02 15:41:37 +00:00
BOOST_STATIC_CONSTANT(int, value = AUX778076_COUNT_ARGS_REPEAT(
AUX778076_COUNT_ARGS_ARITY
, AUX778076_COUNT_ARGS_FUNC
, AUX778076_COUNT_ARGS_PARAM_NAME
2002-09-15 22:13:24 +00:00
));
};
2004-09-02 15:41:37 +00:00
#undef AUX778076_COUNT_ARGS_FUNC
#undef AUX778076_IS_ARG_TEMPLATE_NAME
#undef AUX778076_COUNT_ARGS_PARAMS
#undef AUX778076_COUNT_ARGS_REPEAT
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#undef AUX778076_COUNT_ARGS_ARITY
#undef AUX778076_COUNT_ARGS_DEFAULT
#undef AUX778076_COUNT_ARGS_PREFIX
#undef AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
#undef AUX778076_COUNT_ARGS_TEMPLATE_PARAM
#undef AUX778076_COUNT_ARGS_PARAM_NAME