From f2bfe9dff99c1773b475b8e772933e699acc62f0 Mon Sep 17 00:00:00 2001 From: Peder Holt Date: Thu, 20 Jan 2005 17:18:28 +0000 Subject: [PATCH] Implemented new integral registration scheme (Use Arkadiys version for both TYPEOF implementations). Moved integral tests from compliant area to main.cpp. [SVN r2453] --- include/boost/typeof/register_integral.hpp | 95 +++++++++++++++++++ include/boost/typeof/vintage/concatenate.hpp | 4 +- include/boost/typeof/vintage/int_encoding.hpp | 80 +--------------- .../typeof/vintage/pointers_data_members.hpp | 2 +- .../vintage/register_functions_iterate.hpp | 20 ++-- .../typeof/vintage/register_mem_functions.hpp | 14 +-- .../typeof/vintage/template_encoding.hpp | 87 +++++++++-------- test/main.cpp | 52 ++++++++++ test/vintage/odr.hpp | 2 +- 9 files changed, 220 insertions(+), 136 deletions(-) create mode 100644 include/boost/typeof/register_integral.hpp diff --git a/include/boost/typeof/register_integral.hpp b/include/boost/typeof/register_integral.hpp new file mode 100644 index 0000000..45567f9 --- /dev/null +++ b/include/boost/typeof/register_integral.hpp @@ -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 +#include +#include + +////////// + +#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 diff --git a/include/boost/typeof/vintage/concatenate.hpp b/include/boost/typeof/vintage/concatenate.hpp index f414819..4d0f2e6 100644 --- a/include/boost/typeof/vintage/concatenate.hpp +++ b/include/boost/typeof/vintage/concatenate.hpp @@ -17,7 +17,7 @@ #define BOOST_TYPEOF_DECODE_PARAM(z, n, text) \ typedef decode_impl::decoder 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))); diff --git a/include/boost/typeof/vintage/int_encoding.hpp b/include/boost/typeof/vintage/int_encoding.hpp index 02e2599..08b3614 100644 --- a/include/boost/typeof/vintage/int_encoding.hpp +++ b/include/boost/typeof/vintage/int_encoding.hpp @@ -10,7 +10,7 @@ namespace boost {namespace type_of { template -struct encode_integral_wrapper {}; +struct integral_wrapper {}; template struct encode_integral { @@ -47,7 +47,7 @@ struct encode_integral<0x7FFFFFFF> }; template -typename encode_integral::encoder encode(encode_integral_wrapper const&(*)(V,Types)); +encode_integral::encoder encode(integral_wrapper const&(*)(V,Types)); template struct decode_integral_base { @@ -86,82 +86,6 @@ struct decode_integral : decode_integral_base::decoder -struct encode_unsigned_integral_wrapper {}; - -template -struct encode_unsigned_integral { - template - struct encoder { - BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier::type,typename Types::type,typename Types::next>::encoded_type)); - - friend sizer encode_value(const sizer&,const sizer&); - }; -}; - -template<> -struct encode_unsigned_integral<0xFFFFFFFF> { - template - struct encoder { - BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier::type>::type,typename Types::type,typename Types::next>::encoded_type)); - - friend sizer<0xFFFFFFFF> encode_value(const sizer&,const sizer&); - friend sizer<0xFFFFFFFF> encode_value(const sizer&,const sizer<(V::pos)+1>&); - }; -}; - -template<> -struct encode_unsigned_integral<0xFFFFFFFE> { - template - struct encoder { - BOOST_STATIC_CONSTANT(unsigned,value=sizeof(typename encode_modifier::type>::type,typename Types::type,typename Types::next>::encoded_type)); - - friend sizer<0xFFFFFFFF> encode_value(const sizer&,const sizer&); - friend sizer<0xFFFFFFFE> encode_value(const sizer&,const sizer<(V::pos)+1>&); - }; -}; - -template -typename encode_unsigned_integral::encoder encode(encode_unsigned_integral_wrapper const&(*)(V,Types)); - -template -struct decode_unsigned_integral_base -{ - template - struct decoder { - BOOST_STATIC_CONSTANT(unsigned,value=N-1); - typedef Iter iter; - }; -#if BOOST_WORKAROUND(BOOST_MSVC,<=1300) - template<> - struct decoder { - BOOST_STATIC_CONSTANT(unsigned,value=1); - typedef int iter; - }; -#endif -}; - -template<> -struct decode_unsigned_integral_base<0xFFFFFFFF> { - template - struct decoder { - BOOST_STATIC_CONSTANT(unsigned,value=Iter::value); - typedef typename Iter::next iter; - }; -#if BOOST_WORKAROUND(BOOST_MSVC,<=1300) - template<> - struct decoder { - BOOST_STATIC_CONSTANT(unsigned,value=1); - typedef int iter; - }; -#endif -}; - -template -struct decode_unsigned_integral : decode_unsigned_integral_base::decoder -{ -}; - }}//namespace boost::type_of #endif //BOOST_TYPEOF_INTEGRAL_WRAPPER_HPP_HOLT_2004_0818 diff --git a/include/boost/typeof/vintage/pointers_data_members.hpp b/include/boost/typeof/vintage/pointers_data_members.hpp index a392bd4..3869eed 100644 --- a/include/boost/typeof/vintage/pointers_data_members.hpp +++ b/include/boost/typeof/vintage/pointers_data_members.hpp @@ -50,7 +50,7 @@ namespace boost { namespace type_of{ typedef int type; }; - typedef workaround::type type; + typedef workaround::type type; typedef iter2 iter; }; }; diff --git a/include/boost/typeof/vintage/register_functions_iterate.hpp b/include/boost/typeof/vintage/register_functions_iterate.hpp index 1beba9a..2c772dd 100644 --- a/include/boost/typeof/vintage/register_functions_iterate.hpp +++ b/include/boost/typeof/vintage/register_functions_iterate.hpp @@ -7,7 +7,7 @@ template<> struct encode_impl { - template + template 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 }; }; -template -typename encode_impl::template encoder -encode(R (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) ); +template +typename encode_impl::template encoder +encode(R (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) ); template<> struct decode_impl @@ -38,7 +38,7 @@ struct decode_impl 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 template<> struct encode_impl { - template + template 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 }; }; -template -typename encode_impl::template encoder -encode(R (* const& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) ); +template +typename encode_impl::template encoder +encode(R (* const& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) ); template<> struct decode_impl @@ -77,7 +77,7 @@ struct decode_impl 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; }; }; diff --git a/include/boost/typeof/vintage/register_mem_functions.hpp b/include/boost/typeof/vintage/register_mem_functions.hpp index bd83e76..f4bbc44 100644 --- a/include/boost/typeof/vintage/register_mem_functions.hpp +++ b/include/boost/typeof/vintage/register_mem_functions.hpp @@ -8,7 +8,7 @@ template<> struct encode_impl { - template + template 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 }; }; -template -typename encode_impl::template encoder -encode(R (T::* const&(*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) BOOST_TYPEOF_qualifier); +template +typename encode_impl::template encoder +encode(R (T::* const&(*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,P)) BOOST_TYPEOF_qualifier); template<> struct decode_impl @@ -42,15 +42,15 @@ struct decode_impl typedef typename decodeT::type T; typedef typename decodeT::iter iter0; BOOST_TYPEOF_DECODE_PARAMS(n) - template + template 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 { typedef int type; }; - typedef workaround::type type; + typedef workaround::type type; typedef BOOST_PP_CAT(iter,n) iter; }; }; diff --git a/include/boost/typeof/vintage/template_encoding.hpp b/include/boost/typeof/vintage/template_encoding.hpp index 8d24071..f4c2bcb 100644 --- a/include/boost/typeof/vintage/template_encoding.hpp +++ b/include/boost/typeof/vintage/template_encoding.hpp @@ -13,70 +13,83 @@ #include #include -#include #include #include +#include -//Encoding templates -#define BOOST_TYPEOF_typename_encode(arg) arg -#define BOOST_TYPEOF_integral_encode(arg) encode_integral_wrapper BOOST_PP_EMPTY() -#define BOOST_TYPEOF_unsigned_integral_encode(arg) encode_unsigned_integral_wrapper 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::decoder 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(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::\ + decoder 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(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(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_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\ + struct encode_impl\ {\ - template\ + template\ 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::type,BOOST_DEDUCED_TYPENAME types_0::type,types_1>::encoded_type));\ - friend sizer encode_value(const sizer&,const sizer&);\ + friend sizer encode_value(const sizer&,const sizer&);\ };\ };\ - template\ - typename encode_impl::encoder encode(template_type 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::\ + encoder<\ + V,\ + BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM,Params),\ + Types\ + > encode(Name 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\ + struct decode_impl\ {\ template\ struct decoder {\ typedef Iter iter0;\ - BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_DECODE_SEQ_ELEMENT,seq)\ - typedef template_type 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 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 diff --git a/test/main.cpp b/test/main.cpp index 7d1e178..d3a9905 100755 --- a/test/main.cpp +++ b/test/main.cpp @@ -211,6 +211,58 @@ BOOST_STATIC_ASSERT(typeof_test > >::value); BOOST_STATIC_ASSERT(typeof_test >::value); +#pragma message("compiling integral param wrapper...") + +namespace test_integral +{ + // Enum template parameter + enum E{ONE, TWO, THREE}; + + template struct foo + { + BOOST_STATIC_CONSTANT(E,value=e); + }; + + // dependent template parameter + template struct bar + {}; + + // multi-word template parameter + template 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 x; + bar 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() { diff --git a/test/vintage/odr.hpp b/test/vintage/odr.hpp index 030b48f..a1e564a 100644 --- a/test/vintage/odr.hpp +++ b/test/vintage/odr.hpp @@ -33,7 +33,7 @@ sum_t::sum_t(const T& t, const U& u) {} template -sum_t::result_type sum_t::operator()() +typename sum_t::result_type sum_t::operator()() { // BOOST_AUTO_TPL(result, m_sum); return m_sum;