Implemented new integral registration scheme (Use Arkadiys version for both TYPEOF implementations).

Moved integral tests from compliant area to main.cpp.


[SVN r2453]
This commit is contained in:
Peder Holt
2005-01-20 17:18:28 +00:00
parent 9e10362252
commit f2bfe9dff9
9 changed files with 220 additions and 136 deletions

View File

@ -0,0 +1,95 @@
// Copyright (C) 2004 Arkadiy Vertleyb
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_TYPEOF_REGISTER_INTEGRAL_HPP_INCLUDED
#define BOOST_TYPEOF_REGISTER_INTEGRAL_HPP_INCLUDED
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq.hpp>
#include <boost/preprocessor/repetition/enum_trailing.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_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_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_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)
//////////
#endif//BOOST_TYPEOF_COMPLIANT_TEMPLATE_ENCODING_HPP_INCLUDED

View File

@ -17,7 +17,7 @@
#define BOOST_TYPEOF_DECODE_PARAM(z, n, text) \
typedef decode_impl<TYPEOF_GET_VALUE(iter##n)>::decoder<TYPEOF_GET_NEXT(iter##n)> decode##n;\
typedef typename decode##n::type A##n; \
typedef typename decode##n::type P##n; \
typedef typename decode##n::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n));
#define BOOST_TYPEOF_DECODE_PARAMS(n)\
@ -25,7 +25,7 @@
#define BOOST_TYPEOF_PUSH_FRONT(z,n,template_size)\
typedef type_list<\
BOOST_PP_CAT(A,BOOST_PP_DEC(BOOST_PP_SUB(template_size,n))),\
BOOST_PP_CAT(P,BOOST_PP_DEC(BOOST_PP_SUB(template_size,n))),\
BOOST_PP_CAT(types_,BOOST_PP_SUB(template_size,n))\
> BOOST_PP_CAT(types_,BOOST_PP_DEC(BOOST_PP_SUB(template_size,n)));

View File

@ -10,7 +10,7 @@
namespace boost {namespace type_of {
template<unsigned N>
struct encode_integral_wrapper {};
struct integral_wrapper {};
template<unsigned N>
struct encode_integral {
@ -47,7 +47,7 @@ struct encode_integral<0x7FFFFFFF>
};
template<unsigned N,typename V,typename Types>
typename encode_integral<N>::encoder<V,Types> encode(encode_integral_wrapper<N> const&(*)(V,Types));
encode_integral<N>::encoder<V,Types> encode(integral_wrapper<N> const&(*)(V,Types));
template<unsigned N>
struct decode_integral_base {
@ -86,82 +86,6 @@ struct decode_integral : decode_integral_base<TYPEOF_GET_VALUE(Iter)>::decoder<T
{
};
template<unsigned N>
struct encode_unsigned_integral_wrapper {};
template<unsigned N>
struct encode_unsigned_integral {
template<typename V,typename Types>
struct encoder {
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier<typename mpl::next<V>::type,typename Types::type,typename Types::next>::encoded_type));
friend sizer<N+1> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
};
};
template<>
struct encode_unsigned_integral<0xFFFFFFFF> {
template<typename V,typename Types>
struct encoder {
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier<typename mpl::next<typename mpl::next<V>::type>::type,typename Types::type,typename Types::next>::encoded_type));
friend sizer<0xFFFFFFFF> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
friend sizer<0xFFFFFFFF> encode_value(const sizer<V::index>&,const sizer<(V::pos)+1>&);
};
};
template<>
struct encode_unsigned_integral<0xFFFFFFFE> {
template<typename V,typename Types>
struct encoder {
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier<typename mpl::next<typename mpl::next<V>::type>::type,typename Types::type,typename Types::next>::encoded_type));
friend sizer<0xFFFFFFFF> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
friend sizer<0xFFFFFFFE> encode_value(const sizer<V::index>&,const sizer<(V::pos)+1>&);
};
};
template<unsigned N,typename V,typename Types>
typename encode_unsigned_integral<N>::encoder<V,Types> encode(encode_unsigned_integral_wrapper<N> const&(*)(V,Types));
template<unsigned N>
struct decode_unsigned_integral_base
{
template<typename Iter>
struct decoder {
BOOST_STATIC_CONSTANT(unsigned,value=N-1);
typedef Iter iter;
};
#if BOOST_WORKAROUND(BOOST_MSVC,<=1300)
template<>
struct decoder<int> {
BOOST_STATIC_CONSTANT(unsigned,value=1);
typedef int iter;
};
#endif
};
template<>
struct decode_unsigned_integral_base<0xFFFFFFFF> {
template<typename Iter>
struct decoder {
BOOST_STATIC_CONSTANT(unsigned,value=Iter::value);
typedef typename Iter::next iter;
};
#if BOOST_WORKAROUND(BOOST_MSVC,<=1300)
template<>
struct decoder<int> {
BOOST_STATIC_CONSTANT(unsigned,value=1);
typedef int iter;
};
#endif
};
template<typename Iter>
struct decode_unsigned_integral : decode_unsigned_integral_base<TYPEOF_GET_VALUE(Iter)>::decoder<TYPEOF_GET_NEXT(Iter)>
{
};
}}//namespace boost::type_of
#endif //BOOST_TYPEOF_INTEGRAL_WRAPPER_HPP_HOLT_2004_0818

View File

@ -50,7 +50,7 @@ namespace boost { namespace type_of{
typedef int type;
};
typedef workaround<A0,A1>::type type;
typedef workaround<P0,P1>::type type;
typedef iter2 iter;
};
};

View File

@ -7,7 +7,7 @@
template<>
struct encode_impl<FUN_REF_ID + n>
{
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
struct encoder {
typedef Types BOOST_PP_CAT(types_,n);
BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n)
@ -24,9 +24,9 @@ struct encode_impl<FUN_REF_ID + n>
};
};
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
typename encode_impl<FUN_REF_ID + n>::template encoder<V,R BOOST_PP_ENUM_TRAILING_PARAMS(n,A),Types>
encode(R (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) );
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
typename encode_impl<FUN_REF_ID + n>::template encoder<V,R BOOST_PP_ENUM_TRAILING_PARAMS(n,P),Types>
encode(R (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) );
template<>
struct decode_impl<FUN_REF_ID + n>
@ -38,7 +38,7 @@ struct decode_impl<FUN_REF_ID + n>
typedef typename decodeR::type R;
typedef typename decodeR::iter iter0;
BOOST_TYPEOF_DECODE_PARAMS(n);
typedef R (&type)(BOOST_PP_ENUM_PARAMS(n,A));
typedef R (&type)(BOOST_PP_ENUM_PARAMS(n,P));
typedef BOOST_PP_CAT(iter,n) iter;
};
};
@ -46,7 +46,7 @@ struct decode_impl<FUN_REF_ID + n>
template<>
struct encode_impl<FUN_ID + n>
{
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
struct encoder {
typedef Types BOOST_PP_CAT(types_,n);
BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n)
@ -63,9 +63,9 @@ struct encode_impl<FUN_ID + n>
};
};
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
typename encode_impl<FUN_ID + n>::template encoder<V,R BOOST_PP_ENUM_TRAILING_PARAMS(n,A),Types>
encode(R (* const& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) );
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
typename encode_impl<FUN_ID + n>::template encoder<V,R BOOST_PP_ENUM_TRAILING_PARAMS(n,P),Types>
encode(R (* const& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) );
template<>
struct decode_impl<FUN_ID + n>
@ -77,7 +77,7 @@ struct decode_impl<FUN_ID + n>
typedef typename decodeR::type R;
typedef typename decodeR::iter iter0;
BOOST_TYPEOF_DECODE_PARAMS(n);
typedef R (*type)(BOOST_PP_ENUM_PARAMS(n,A));
typedef R (*type)(BOOST_PP_ENUM_PARAMS(n,P));
typedef BOOST_PP_CAT(iter,n) iter;
};
};

View File

@ -8,7 +8,7 @@
template<>
struct encode_impl<BOOST_TYPEOF_id + n>
{
template<typename V,typename R,typename T BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
template<typename V,typename R,typename T BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
struct encoder {
typedef Types BOOST_PP_CAT(types_,n);
BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n)
@ -25,9 +25,9 @@ struct encode_impl<BOOST_TYPEOF_id + n>
};
};
template<typename V,typename R,typename T BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
typename encode_impl<BOOST_TYPEOF_id + n>::template encoder<V,R,T BOOST_PP_ENUM_TRAILING_PARAMS(n,A),Types>
encode(R (T::* const&(*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) BOOST_TYPEOF_qualifier);
template<typename V,typename R,typename T BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P),typename Types>
typename encode_impl<BOOST_TYPEOF_id + n>::template encoder<V,R,T BOOST_PP_ENUM_TRAILING_PARAMS(n,P),Types>
encode(R (T::* const&(*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) BOOST_TYPEOF_qualifier);
template<>
struct decode_impl<BOOST_TYPEOF_id + n>
@ -42,15 +42,15 @@ struct decode_impl<BOOST_TYPEOF_id + n>
typedef typename decodeT::type T;
typedef typename decodeT::iter iter0;
BOOST_TYPEOF_DECODE_PARAMS(n)
template<typename R_,typename T_ BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A_)>
template<typename R_,typename T_ BOOST_PP_ENUM_TRAILING_PARAMS(n,typename P_)>
struct workaround {
typedef R_ (T_::*type)(BOOST_PP_ENUM_PARAMS(n,A_)) BOOST_TYPEOF_qualifier;
typedef R_ (T_::*type)(BOOST_PP_ENUM_PARAMS(n,P_)) BOOST_TYPEOF_qualifier;
};
template<>
struct workaround<int,int BOOST_PP_ENUM_TRAILING_PARAMS(n,int BOOST_PP_INTERCEPT)> {
typedef int type;
};
typedef workaround<R,T BOOST_PP_ENUM_TRAILING_PARAMS(n,A)>::type type;
typedef workaround<R,T BOOST_PP_ENUM_TRAILING_PARAMS(n,P)>::type type;
typedef BOOST_PP_CAT(iter,n) iter;
};
};

View File

@ -13,70 +13,83 @@
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/typeof/config.hpp>
#include <boost/typeof/vintage/type_to_macro.hpp>
#include <boost/typeof/vintage/encode_decode.hpp>
#include <boost/typeof/vintage/int_encoding.hpp>
#include <boost/typeof/register_integral.hpp>
//Encoding templates
#define BOOST_TYPEOF_typename_encode(arg) arg
#define BOOST_TYPEOF_integral_encode(arg) encode_integral_wrapper<arg> BOOST_PP_EMPTY()
#define BOOST_TYPEOF_unsigned_integral_encode(arg) encode_unsigned_integral_wrapper<arg> BOOST_PP_EMPTY()
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_TYPE(n, Params)\
BOOST_PP_CAT(P, n)
//Decoding templates
#define BOOST_TYPEOF_typename_decode(n,text) \
typedef typename decode_impl<TYPEOF_GET_VALUE(BOOST_PP_CAT(iter,n))>::decoder<TYPEOF_GET_NEXT(BOOST_PP_CAT(iter,n))> BOOST_PP_CAT(decode,n);\
typedef typename BOOST_PP_CAT(decode,n)::type BOOST_PP_CAT(A,n);\
typedef typename BOOST_PP_CAT(decode,n)::iter BOOST_PP_CAT(iter,BOOST_PP_INC(n));
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_VALUE(n, Params)\
integral_wrapper<\
BOOST_PP_CAT(P, n)\
>
#define BOOST_TYPEOF_integral_decode(n,text) \
typedef decode_integral<BOOST_PP_CAT(iter,n)> BOOST_PP_CAT(decode,n);\
BOOST_STATIC_CONSTANT(text,BOOST_PP_CAT(A,n)=(TYPEOF_GET_VALUE(BOOST_PP_CAT(decode,n))));\
typedef typename BOOST_PP_CAT(decode,n)::iter BOOST_PP_CAT(iter,BOOST_PP_INC(n));
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_TYPE(n, PARAMS)\
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_unsigned_integral_decode(n,text) \
typedef decode_unsigned_integral<BOOST_PP_CAT(iter,n)> BOOST_PP_CAT(decode,n);\
BOOST_STATIC_CONSTANT(text,BOOST_PP_CAT(A,n)=(BOOST_PP_CAT(decode,n)::value));\
typedef typename BOOST_PP_CAT(decode,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_ENCODE_SEQ(z,n,seq)\
BOOST_PP_SEQ_ELEM(n, seq) BOOST_PP_CAT(A,n)
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_CAST_TYPE(n,Params)\
BOOST_PP_CAT(P,n)
#define BOOST_TYPEOF_STORE_TYPE_START(z,n,seq) type_list<BOOST_TYPEOF_ENCODE_SEQ_ELEMENT(z,n,seq),
#define BOOST_TYPEOF_STORE_TYPE_END(z,n,seq) > BOOST_PP_EMPTY()
#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_TEMPLATE(template_type,seq)\
#define BOOST_TYPEOF_ENCODE_TEMPLATE_X_IMPL(Name, Params, ID)\
template<>\
struct encode_impl<BOOST_TYPEOF_UNIQUE_ID()>\
struct encode_impl<ID>\
{\
template<typename V, BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(seq),typename A),typename Types>\
template<typename V, BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params),typename P),typename Types>\
struct encoder {\
typedef Types BOOST_PP_CAT(types_,BOOST_PP_SEQ_SIZE(seq));\
BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_PUSH_FRONT,BOOST_PP_SEQ_SIZE(seq))\
typedef Types BOOST_PP_CAT(types_,BOOST_PP_SEQ_SIZE(Params));\
BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_PUSH_FRONT,BOOST_PP_SEQ_SIZE(Params))\
BOOST_STATIC_CONSTANT(int,value =sizeof(BOOST_DEDUCED_TYPENAME encode_modifier<mpl::next<V>::type,BOOST_DEDUCED_TYPENAME types_0::type,types_1>::encoded_type));\
friend sizer<BOOST_TYPEOF_UNIQUE_ID()> encode_value(const sizer<V::index>&,const sizer<V::pos>&);\
friend sizer<ID> encode_value(const sizer<V::index>&,const sizer<V::pos>&);\
};\
};\
template<BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_ENCODE_SEQ,seq),typename V,typename Types>\
typename encode_impl<BOOST_TYPEOF_UNIQUE_ID()>::encoder<V,BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_ENCODE_SEQ_ELEMENT,seq),Types> encode(template_type<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(seq),A)> const& (*)(V,Types));
template<\
BOOST_PP_ENUM(\
BOOST_PP_SEQ_SIZE(Params),\
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),\
Types\
> encode(Name<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params),P)> const& (*)(V,Types));
#define BOOST_TYPEOF_DECODE_TEMPLATE(template_type,seq)\
#define BOOST_TYPEOF_DECODE_TEMPLATE_X_IMPL(Name, Params, ID)\
template<>\
struct decode_impl<BOOST_TYPEOF_UNIQUE_ID()>\
struct decode_impl<ID>\
{\
template<typename Iter>\
struct decoder {\
typedef Iter iter0;\
BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_DECODE_SEQ_ELEMENT,seq)\
typedef template_type<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(seq),A)> type;\
typedef BOOST_PP_CAT(iter,BOOST_PP_SEQ_SIZE(seq)) iter;\
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;\
typedef BOOST_PP_CAT(iter,BOOST_PP_SEQ_SIZE(Params)) iter;\
};\
};
#define BOOST_TYPEOF_REGISTER_TEMPLATE_X(template_type,seq)\
namespace boost { namespace type_of{\
BOOST_TYPEOF_ENCODE_TEMPLATE(template_type,seq)\
BOOST_TYPEOF_DECODE_TEMPLATE(template_type,seq)\
BOOST_TYPEOF_ENCODE_TEMPLATE_X_IMPL(template_type,seq,BOOST_TYPEOF_UNIQUE_ID())\
BOOST_TYPEOF_DECODE_TEMPLATE_X_IMPL(template_type,seq,BOOST_TYPEOF_UNIQUE_ID())\
}}//namespace boost::type_of
#endif //BOOST_VINTAGE_TEMPLATE_ENCODING_HPP_INCLUDED

View File

@ -211,6 +211,58 @@ BOOST_STATIC_ASSERT(typeof_test<binder2nd<less<int> > >::value);
BOOST_STATIC_ASSERT(typeof_test<valarray<int> >::value);
#pragma message("compiling integral param wrapper...")
namespace test_integral
{
// Enum template parameter
enum E{ONE, TWO, THREE};
template<E e> struct foo
{
BOOST_STATIC_CONSTANT(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;
}
}
#pragma message("ODR...")
void odr_test()
{

View File

@ -33,7 +33,7 @@ sum_t<T,U>::sum_t(const T& t, const U& u)
{}
template<class T, class U>
sum_t<T,U>::result_type sum_t<T,U>::operator()()
typename sum_t<T,U>::result_type sum_t<T,U>::operator()()
{
// BOOST_AUTO_TPL(result, m_sum);
return m_sum;