mirror of
https://github.com/boostorg/typeof.git
synced 2025-07-31 21:34:42 +02:00
refactored template encoding in polymorphic-like manner
[SVN r2455]
This commit is contained in:
@@ -7,123 +7,56 @@
|
||||
|
||||
#include <boost/typeof/compliant/encode_decode.hpp>
|
||||
#include <boost/typeof/compliant/int_encoding.hpp>
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing.hpp>
|
||||
#include <boost/typeof/register_integral.hpp>
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_class_ BOOST_TYPEOF_REGISTER_TEMPLATE_typename_
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_typename_ (typename)(TYPE)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_integral(x) (x)(VALUE)
|
||||
// TYPE_PARAM "virtual functions" implementation
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_char_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_short_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_int_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_long_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(long)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_bool_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(bool)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsigned_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_size_t_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(size_t)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedchar BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedshort BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedint BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedlong BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned long)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_signedchar BOOST_TYPEOF_REGISTER_TEMPLATE_integral(signed char)
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_TO_SEQ(tokens) BOOST_TYPEOF_ ## tokens ## _BOOST_TYPEOF
|
||||
|
||||
#define BOOST_TYPEOF_unsigned (unsigned)
|
||||
#define BOOST_TYPEOF_signed (signed)
|
||||
|
||||
#define BOOST_TYPEOF_char_BOOST_TYPEOF (char)(_)
|
||||
#define BOOST_TYPEOF_short_BOOST_TYPEOF (short)(_)
|
||||
#define BOOST_TYPEOF_int_BOOST_TYPEOF (int)(_)
|
||||
#define BOOST_TYPEOF_long_BOOST_TYPEOF (long)(_)
|
||||
#define BOOST_TYPEOF_bool_BOOST_TYPEOF (bool)(_)
|
||||
#define BOOST_TYPEOF_class_BOOST_TYPEOF (class)(_)
|
||||
#define BOOST_TYPEOF_typename_BOOST_TYPEOF (typename)(_)
|
||||
#define BOOST_TYPEOF_unsigned_BOOST_TYPEOF (unsigned)(_)
|
||||
#define BOOST_TYPEOF_size_t_BOOST_TYPEOF (size_t)(_)
|
||||
|
||||
#define char_BOOST_TYPEOF (char)
|
||||
#define short_BOOST_TYPEOF (short)
|
||||
#define int_BOOST_TYPEOF (int)
|
||||
#define long_BOOST_TYPEOF (long)
|
||||
|
||||
#define EAT_SPACE(tokens) BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_TO_SEQ(tokens)), BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_TO_SEQ(tokens)))
|
||||
|
||||
///////////
|
||||
|
||||
#define BOOST_TYPEOF_INTEGRAL(X) REGISTER_TEMPLATE_INTEGRAL(X) BOOST_TYPEOF_EAT
|
||||
#define BOOST_TYPEOF_EAT_BOOST_TYPEOF
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_INTEGRAL(X) (inte)(gral(X))
|
||||
|
||||
///////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_REGISTER_TEMPLATE_, EAT_SPACE(BOOST_PP_SEQ_ELEM(n, Params)))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_TYPE(n, Params)\
|
||||
#define BOOST_TYPEOF_ENCODE_TYPE_PARAM(This, n)\
|
||||
typedef typename encode_type<\
|
||||
BOOST_PP_CAT(V, n),\
|
||||
BOOST_PP_CAT(P, n)\
|
||||
>::type BOOST_PP_CAT(V, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_VALUE(n, Params)\
|
||||
typedef typename encode_integral<\
|
||||
BOOST_PP_CAT(V, n),\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params),\
|
||||
BOOST_PP_CAT(P, n)\
|
||||
>::type BOOST_PP_CAT(V, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_TYPE(n, PARAMS)\
|
||||
#define BOOST_TYPEOF_DECODE_TYPE_PARAM(This, n)\
|
||||
typedef decode_type< BOOST_PP_CAT(iter, n) > BOOST_PP_CAT(d, n);\
|
||||
typedef typename BOOST_PP_CAT(d, n)::type BOOST_PP_CAT(P, n);\
|
||||
typedef typename BOOST_PP_CAT(d, n)::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_VALUE(n, Params)\
|
||||
typedef decode_integral< BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params), BOOST_PP_CAT(iter, n) > BOOST_PP_CAT(d, n);\
|
||||
static const BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params) BOOST_PP_CAT(P, n) = BOOST_PP_CAT(d, n)::value;\
|
||||
// INTEGRAL_PARAM "virtual functions" implementation
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_INTEGRAL_PARAM(This, n)\
|
||||
typedef typename encode_integral<\
|
||||
BOOST_PP_CAT(V, n),\
|
||||
BOOST_TYPEOF_PARAM_GETTYPE(This),\
|
||||
BOOST_PP_CAT(P, n)\
|
||||
>::type BOOST_PP_CAT(V, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_INTEGRAL_PARAM(This, n)\
|
||||
typedef decode_integral<BOOST_TYPEOF_PARAM_GETTYPE(This), BOOST_PP_CAT(iter, n)> BOOST_PP_CAT(d, n);\
|
||||
static const BOOST_TYPEOF_PARAM_GETTYPE(This) BOOST_PP_CAT(P, n) = BOOST_PP_CAT(d, n)::value;\
|
||||
typedef typename BOOST_PP_CAT(d, n)::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(z, n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_,\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
)(n, Params)
|
||||
// "function objects"
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(z, n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_,\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
)(n, Params)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(r, data, n, elem)\
|
||||
BOOST_TYPEOF_PARAM_ENCODE(BOOST_TYPEOF_MAKE_OBJ(elem))(BOOST_TYPEOF_MAKE_OBJ(elem), n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(z, n, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params) BOOST_PP_CAT(P, n)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(r, data, n, elem)\
|
||||
BOOST_TYPEOF_PARAM_DECODE(BOOST_TYPEOF_MAKE_OBJ(elem))(BOOST_TYPEOF_MAKE_OBJ(elem), n)
|
||||
|
||||
//////////
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(r, data, n, elem)\
|
||||
, BOOST_TYPEOF_PARAM_GETTYPE(BOOST_TYPEOF_MAKE_OBJ(elem)) BOOST_PP_CAT(P, n)
|
||||
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_X_IMPL(Name, Params, ID)\
|
||||
namespace boost{namespace type_of{namespace{\
|
||||
template<class V\
|
||||
BOOST_PP_ENUM_TRAILING(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR,\
|
||||
~,\
|
||||
Params)\
|
||||
>\
|
||||
struct encode_type_impl<V, Name<\
|
||||
@@ -132,9 +65,9 @@
|
||||
P)> >\
|
||||
{\
|
||||
typedef typename BOOST_TYPEOF_PUSH_BACK<V, boost::mpl::size_t<ID> >::type V0;\
|
||||
BOOST_PP_REPEAT(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM,\
|
||||
~,\
|
||||
Params)\
|
||||
typedef BOOST_PP_CAT(V, BOOST_PP_SEQ_SIZE(Params)) type;\
|
||||
};\
|
||||
@@ -142,9 +75,9 @@
|
||||
struct decode_type_impl<boost::mpl::size_t<ID>, Iter>\
|
||||
{\
|
||||
typedef Iter iter0;\
|
||||
BOOST_PP_REPEAT(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM,\
|
||||
~,\
|
||||
Params)\
|
||||
typedef Name< BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params), P) > type;\
|
||||
typedef BOOST_PP_CAT(iter, BOOST_PP_SEQ_SIZE(Params)) iter;\
|
||||
|
@@ -9,87 +9,78 @@
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing.hpp>
|
||||
|
||||
//////////
|
||||
// The template parameter description, entered by the user,
|
||||
// is converted into a polymorphic "object"
|
||||
// that is used to generate the code responsible for
|
||||
// encoding/decoding the parameter, etc.
|
||||
// See also compliant/template_encoding.hpp and
|
||||
// vintage/template_encoding.hpp.
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_class_ BOOST_TYPEOF_REGISTER_TEMPLATE_typename_
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_typename_ (typename)(TYPE)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_integral(x) (x)(VALUE)
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_char_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_short_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_int_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_long_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(long)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_bool_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(bool)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsigned_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_size_t_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(size_t)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedchar BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedshort BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedint BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedlong BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned long)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_signedchar BOOST_TYPEOF_REGISTER_TEMPLATE_integral(signed char)
|
||||
|
||||
//////////
|
||||
#define BOOST_TYPEOF_MAKE_OBJ(elem) BOOST_PP_SEQ_CAT(\
|
||||
(BOOST_TYPEOF_MAKE_OBJ_) BOOST_TYPEOF_TO_SEQ(elem))
|
||||
|
||||
#define BOOST_TYPEOF_TO_SEQ(tokens) BOOST_TYPEOF_ ## tokens ## _BOOST_TYPEOF
|
||||
|
||||
#define BOOST_TYPEOF_unsigned (unsigned)
|
||||
#define BOOST_TYPEOF_signed (signed)
|
||||
|
||||
#define BOOST_TYPEOF_char_BOOST_TYPEOF (char)(_)
|
||||
#define BOOST_TYPEOF_short_BOOST_TYPEOF (short)(_)
|
||||
#define BOOST_TYPEOF_int_BOOST_TYPEOF (int)(_)
|
||||
#define BOOST_TYPEOF_long_BOOST_TYPEOF (long)(_)
|
||||
#define BOOST_TYPEOF_bool_BOOST_TYPEOF (bool)(_)
|
||||
#define BOOST_TYPEOF_class_BOOST_TYPEOF (class)(_)
|
||||
#define BOOST_TYPEOF_typename_BOOST_TYPEOF (typename)(_)
|
||||
#define BOOST_TYPEOF_unsigned_BOOST_TYPEOF (unsigned)(_)
|
||||
#define BOOST_TYPEOF_size_t_BOOST_TYPEOF (size_t)(_)
|
||||
|
||||
#define char_BOOST_TYPEOF (char)
|
||||
#define short_BOOST_TYPEOF (short)
|
||||
#define int_BOOST_TYPEOF (int)
|
||||
#define long_BOOST_TYPEOF (long)
|
||||
|
||||
#define EAT_SPACE(tokens) BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_TO_SEQ(tokens)), BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_TO_SEQ(tokens)))
|
||||
#define BOOST_TYPEOF_char_BOOST_TYPEOF (char)
|
||||
#define BOOST_TYPEOF_short_BOOST_TYPEOF (short)
|
||||
#define BOOST_TYPEOF_int_BOOST_TYPEOF (int)
|
||||
#define BOOST_TYPEOF_long_BOOST_TYPEOF (long)
|
||||
#define BOOST_TYPEOF_bool_BOOST_TYPEOF (bool)
|
||||
#define BOOST_TYPEOF_class_BOOST_TYPEOF (class)
|
||||
#define BOOST_TYPEOF_typename_BOOST_TYPEOF (typename)
|
||||
#define BOOST_TYPEOF_unsigned_BOOST_TYPEOF (unsigned)
|
||||
#define BOOST_TYPEOF_size_t_BOOST_TYPEOF (size_t)
|
||||
|
||||
///////////
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_class BOOST_TYPEOF_TYPE_PARAM
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_typename BOOST_TYPEOF_TYPE_PARAM
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_char BOOST_TYPEOF_INTEGRAL_PARAM(char)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_short BOOST_TYPEOF_INTEGRAL_PARAM(short)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_int BOOST_TYPEOF_INTEGRAL_PARAM(int)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_long BOOST_TYPEOF_INTEGRAL_PARAM(long)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_bool BOOST_TYPEOF_INTEGRAL_PARAM(bool)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_unsigned BOOST_TYPEOF_INTEGRAL_PARAM(unsigned)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_size_t BOOST_TYPEOF_INTEGRAL_PARAM(size_t)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_unsignedchar BOOST_TYPEOF_INTEGRAL_PARAM(unsigned char)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_unsignedshort BOOST_TYPEOF_INTEGRAL_PARAM(unsigned short)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_unsignedint BOOST_TYPEOF_INTEGRAL_PARAM(unsigned int)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_unsignedlong BOOST_TYPEOF_INTEGRAL_PARAM(unsigned long)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_signedchar BOOST_TYPEOF_INTEGRAL_PARAM(signed char)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_signedshort BOOST_TYPEOF_INTEGRAL_PARAM(signed short)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_signedint BOOST_TYPEOF_INTEGRAL_PARAM(signed int)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_signedlong BOOST_TYPEOF_INTEGRAL_PARAM(signed long)
|
||||
#define BOOST_TYPEOF_MAKE_OBJ_integral(x) BOOST_TYPEOF_INTEGRAL_PARAM(x)
|
||||
|
||||
#define BOOST_TYPEOF_INTEGRAL(X) REGISTER_TEMPLATE_INTEGRAL(X) BOOST_TYPEOF_EAT
|
||||
#define BOOST_TYPEOF_INTEGRAL(X) integral(X) BOOST_TYPEOF_EAT
|
||||
#define BOOST_TYPEOF_EAT_BOOST_TYPEOF
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_INTEGRAL(X) (inte)(gral(X))
|
||||
#define BOOST_TYPEOF_integral(X) (integral(X))
|
||||
|
||||
///////////
|
||||
// "interface"
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_REGISTER_TEMPLATE_, EAT_SPACE(BOOST_PP_SEQ_ELEM(n, Params)))
|
||||
#define BOOST_TYPEOF_PARAM_ENCODE(Param)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_ENCODE_, BOOST_PP_SEQ_ELEM(0, Param))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
#define BOOST_TYPEOF_PARAM_DECODE(Param)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_DECODE_, BOOST_PP_SEQ_ELEM(0, Param))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
#define BOOST_TYPEOF_PARAM_GETTYPE(Param)\
|
||||
BOOST_PP_SEQ_ELEM(1, Param)
|
||||
|
||||
//////////
|
||||
// "constructors"
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(z, n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_,\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
)(n, Params)
|
||||
#define BOOST_TYPEOF_TYPE_PARAM\
|
||||
(TYPE_PARAM)\
|
||||
(class)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(z, n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_,\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
)(n, Params)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(z, n, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params) BOOST_PP_CAT(P, n)
|
||||
|
||||
//////////
|
||||
#define BOOST_TYPEOF_INTEGRAL_PARAM(Type)\
|
||||
(INTEGRAL_PARAM)\
|
||||
(Type)
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
|
@@ -11,42 +11,62 @@
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
|
||||
#include <boost/typeof/config.hpp>
|
||||
#include <boost/typeof/vintage/encode_decode.hpp>
|
||||
#include <boost/typeof/vintage/int_encoding.hpp>
|
||||
#include <boost/typeof/register_integral.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_TYPE(n, Params)\
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_PARAM_CAST(Param)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_CAST_, BOOST_PP_SEQ_ELEM(0, Param))
|
||||
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_TYPE_PARAM(This, n)\
|
||||
BOOST_PP_CAT(P, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_VALUE(n, Params)\
|
||||
integral_wrapper<\
|
||||
BOOST_PP_CAT(P, n)\
|
||||
>
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_TYPE(n, PARAMS)\
|
||||
#define BOOST_TYPEOF_DECODE_TYPE_PARAM(This, n)\
|
||||
typedef typename decode_impl<TYPEOF_GET_VALUE(BOOST_PP_CAT(iter,n))>::\
|
||||
decoder<TYPEOF_GET_NEXT(BOOST_PP_CAT(iter,n))> BOOST_PP_CAT(d,n);\
|
||||
typedef typename BOOST_PP_CAT(d,n)::type BOOST_PP_CAT(P,n);\
|
||||
typedef typename BOOST_PP_CAT(d,n)::iter BOOST_PP_CAT(iter,BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_VALUE(n, Params)\
|
||||
typedef decode_integral<BOOST_PP_CAT(iter,n)> BOOST_PP_CAT(d,n);\
|
||||
BOOST_STATIC_CONSTANT(BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params),BOOST_PP_CAT(P,n)=(TYPEOF_GET_VALUE(BOOST_PP_CAT(d,n))));\
|
||||
typedef typename BOOST_PP_CAT(d,n)::iter BOOST_PP_CAT(iter,BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST_VALUE(n,Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params)(BOOST_PP_CAT(P,n))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST_TYPE(n,Params)\
|
||||
#define BOOST_TYPEOF_CAST_TYPE_PARAM(This, n)\
|
||||
BOOST_PP_CAT(P,n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST(z, n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST_,\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SUFFIX(n, Params)\
|
||||
)(n, Params)
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_INTEGRAL_PARAM(This, n)\
|
||||
integral_wrapper<\
|
||||
BOOST_PP_CAT(P, n)\
|
||||
>
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_INTEGRAL_PARAM(This, n)\
|
||||
typedef decode_integral<BOOST_PP_CAT(iter,n)> BOOST_PP_CAT(d,n);\
|
||||
BOOST_STATIC_CONSTANT(BOOST_TYPEOF_PARAM_GETTYPE(This),BOOST_PP_CAT(P,n)=(TYPEOF_GET_VALUE(BOOST_PP_CAT(d,n))));\
|
||||
typedef typename BOOST_PP_CAT(d,n)::iter BOOST_PP_CAT(iter,BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_CAST_INTEGRAL_PARAM(This, n)\
|
||||
BOOST_TYPEOF_PARAM_GETTYPE(This)(BOOST_PP_CAT(P,n))
|
||||
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(r, data, n, elem)\
|
||||
BOOST_TYPEOF_PARAM_DECODE(BOOST_TYPEOF_MAKE_OBJ(elem))(BOOST_TYPEOF_MAKE_OBJ(elem), n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(r, data, n, elem)\
|
||||
, BOOST_TYPEOF_PARAM_ENCODE(BOOST_TYPEOF_MAKE_OBJ(elem))(BOOST_TYPEOF_MAKE_OBJ(elem), n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(r, data, n, elem)\
|
||||
BOOST_PP_COMMA_IF(n) BOOST_TYPEOF_PARAM_GETTYPE(BOOST_TYPEOF_MAKE_OBJ(elem)) BOOST_PP_CAT(P, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST(r, data, n, elem)\
|
||||
BOOST_PP_COMMA_IF(n) BOOST_TYPEOF_PARAM_CAST(BOOST_TYPEOF_MAKE_OBJ(elem))(BOOST_TYPEOF_MAKE_OBJ(elem), n)
|
||||
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_TEMPLATE_X_IMPL(Name, Params, ID)\
|
||||
template<>\
|
||||
@@ -61,15 +81,15 @@
|
||||
};\
|
||||
};\
|
||||
template<\
|
||||
BOOST_PP_ENUM(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR,\
|
||||
~,\
|
||||
Params\
|
||||
),typename V,typename Types>\
|
||||
typename encode_impl<ID>::\
|
||||
encoder<\
|
||||
V,\
|
||||
BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM,Params),\
|
||||
V\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM,~,Params),\
|
||||
Types\
|
||||
> encode(Name<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params),P)> const& (*)(V,Types));
|
||||
|
||||
@@ -80,8 +100,8 @@
|
||||
template<typename Iter>\
|
||||
struct decoder {\
|
||||
typedef Iter iter0;\
|
||||
BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM,Params)\
|
||||
typedef Name<BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST,Params)> type;\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM,~,Params)\
|
||||
typedef Name<BOOST_PP_SEQ_FOR_EACH_I(BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST,~,Params)> type;\
|
||||
typedef BOOST_PP_CAT(iter,BOOST_PP_SEQ_SIZE(Params)) iter;\
|
||||
};\
|
||||
};
|
||||
|
@@ -61,55 +61,3 @@ void test_spirit2()
|
||||
if (!success)
|
||||
throw 0;
|
||||
}
|
||||
|
||||
#pragma message("compiling integral param wrapper...")
|
||||
|
||||
namespace test_integral
|
||||
{
|
||||
// Enum template parameter
|
||||
enum E{ONE, TWO, THREE};
|
||||
|
||||
template<E e> struct foo
|
||||
{
|
||||
static const E value = e;
|
||||
};
|
||||
|
||||
// dependent template parameter
|
||||
template<class T, T n> struct bar
|
||||
{};
|
||||
|
||||
// multi-word template parameter
|
||||
template<unsigned long int n> struct blah
|
||||
{};
|
||||
}
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::foo,
|
||||
(BOOST_TYPEOF_INTEGRAL(test_integral::E))
|
||||
);
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::blah,
|
||||
(BOOST_TYPEOF_INTEGRAL(unsigned long int))
|
||||
);
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::bar,
|
||||
(class)
|
||||
(BOOST_TYPEOF_INTEGRAL(P0))
|
||||
);
|
||||
|
||||
namespace test_integral
|
||||
{
|
||||
void test()
|
||||
{
|
||||
foo<TWO> x;
|
||||
bar<int, 5> xx;
|
||||
blah<5> xxx;
|
||||
|
||||
BOOST_AUTO(y, x);
|
||||
BOOST_AUTO(yy, xx);
|
||||
BOOST_AUTO(yyy, xxx);
|
||||
|
||||
y;
|
||||
yy;
|
||||
yyy;
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="C:\boost\boost_1_32_0;..\..\..\.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
GeneratePreprocessedFile="0"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
@@ -69,8 +68,9 @@
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""C:\ark\boost-sandbox\boost-sandbox""
|
||||
AdditionalIncludeDirectories="C:\boost\boost_1_32_0;..\..\..\.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
GeneratePreprocessedFile="0"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
@@ -172,6 +172,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\register_fundamental.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\register_integral.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\register_mem_functions.hpp">
|
||||
</File>
|
||||
|
@@ -276,6 +276,7 @@ void odr_test()
|
||||
int main()
|
||||
{
|
||||
odr_test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma message("done!")
|
||||
|
Reference in New Issue
Block a user