diff --git a/include/boost/typeof/vintage/concatenate.hpp b/include/boost/typeof/vintage/concatenate.hpp new file mode 100644 index 0000000..f414819 --- /dev/null +++ b/include/boost/typeof/vintage/concatenate.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_CONCATENATE_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_CONCATENATE_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +#include +// Assumes iter0 contains initial iterator + +#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::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n)); + +#define BOOST_TYPEOF_DECODE_PARAMS(n)\ + BOOST_PP_REPEAT(n, BOOST_TYPEOF_DECODE_PARAM, _); + +#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(types_,BOOST_PP_SUB(template_size,n))\ + > BOOST_PP_CAT(types_,BOOST_PP_DEC(BOOST_PP_SUB(template_size,n))); + +#endif//BOOST_TYPEOF_CONCATENATE_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/config.hpp b/include/boost/typeof/vintage/config.hpp new file mode 100644 index 0000000..249d9d2 --- /dev/null +++ b/include/boost/typeof/vintage/config.hpp @@ -0,0 +1,74 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#include + +#ifndef BOOST_TYPEOF_VINTAGE_CONFIG_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_CONFIG_HPP_INCLUDED + +#ifndef BOOST_MAX_TYPEOF_COUNTER +#define BOOST_MAX_TYPEOF_COUNTER 1000 +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +# define BOOST_MIN_TYPEOF_COUNTER 5 +#else +# define BOOST_MIN_TYPEOF_COUNTER 1 +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +#define TYPEOF_MSVC_ETI_WRAPPER(name) \ +namespace boost { namespace type_of { namespace detail \ +{ \ + template \ + struct BOOST_PP_CAT(get_, name) \ + { \ + typedef typename T::name type; \ + }; \ + \ + template <> \ + struct BOOST_PP_CAT(get_, name) \ + { \ + typedef int type; \ + }; \ +}}} +#endif //BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +TYPEOF_MSVC_ETI_WRAPPER(next) +# define TYPEOF_GET_NEXT(T) ::boost::type_of::detail::get_next::type +#else +# define TYPEOF_GET_NEXT(T) typename T::next +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) \ + || BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +namespace boost { namespace type_of { namespace detail +{ + template + struct get_value + { + BOOST_STATIC_CONSTANT(int, value = T::value); + }; + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + + // VC6 ETI (early template instantiation) bug workaround. + template <> + struct get_value + { + BOOST_STATIC_CONSTANT(int, value = 0); + }; +#endif +}}} +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) \ + || BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +# define TYPEOF_GET_VALUE(T) ::boost::type_of::detail::get_value::value +#else +# define TYPEOF_GET_VALUE(T) T::value +#endif + +#endif //BOOST_TYPEOF_VINTAGE_CONFIG_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/encode_decode.hpp b/include/boost/typeof/vintage/encode_decode.hpp new file mode 100644 index 0000000..c409213 --- /dev/null +++ b/include/boost/typeof/vintage/encode_decode.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_ENCODE_DECODE_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_ENCODE_DECODE_HPP_INCLUDED + +#define BOOST_TYPEOF_UNIQUE_ID()\ + BOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__ + +#define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\ + + +#include + +namespace boost +{ + namespace type_of + { + template + struct encode_impl { + template + struct encoder { + }; + }; + template + struct decode_impl{ + template + struct decoder { + typedef int type; + typedef int iter; + }; + #if BOOST_WORKAROUND(BOOST_MSVC,<=1300) + template<> + struct decoder { + typedef int type; + typedef int iter; + }; + #endif + }; + + template + struct encode_modifier { + BOOST_STATIC_CONSTANT(unsigned,value=modifier_category::value); + typedef typename encode_impl::template encoder encoded_type; + }; + } +} + +#endif//BOOST_TYPEOF_VINTAGE_ENCODE_DECODE_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/int_encoding.hpp b/include/boost/typeof/vintage/int_encoding.hpp new file mode 100644 index 0000000..02e2599 --- /dev/null +++ b/include/boost/typeof/vintage/int_encoding.hpp @@ -0,0 +1,167 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_INT_ENCODING_HPP_INCLUDED +#define BOOST_TYPEOF_VINTATE_INT_ENCODING_HPP_INCLUDED + +#include + +namespace boost {namespace type_of { + +template +struct encode_integral_wrapper {}; + +template +struct encode_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&); + }; +}; +//Special implementation for 0x80000000 and 0x7FFFFFFF in order to allow representation of all numbers +template<> +struct encode_integral<0x80000000> +{ + 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<0x80000000> encode_value(const sizer&,const sizer<(V::pos)+1>&); + }; +}; + +template<> +struct encode_integral<0x7FFFFFFF> +{ + 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<0x7FFFFFFF> encode_value(const sizer&,const sizer<(V::pos)+1>&); + }; +}; + +template +typename encode_integral::encoder encode(encode_integral_wrapper const&(*)(V,Types)); + +template +struct decode_integral_base { + template + struct decoder { + BOOST_STATIC_CONSTANT(int,value=N^0x80000000); + 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_integral_base<0xFFFFFFFF> { + template + struct decoder { + BOOST_STATIC_CONSTANT(int,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_integral : decode_integral_base::decoder +{ +}; + +template +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/is_pointer.hpp b/include/boost/typeof/vintage/is_pointer.hpp new file mode 100644 index 0000000..33e6bb8 --- /dev/null +++ b/include/boost/typeof/vintage/is_pointer.hpp @@ -0,0 +1,54 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_IS_POINTER_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_IS_POINTER_HPP_INCLUDED + +#include +#include + +namespace boost { namespace type_of { + template + boost::detail::yes_type is_pointer_tester(T*); + boost::detail::no_type is_pointer_tester(...); + + template + struct is_pointer_select + : ::boost::type_traits::false_result + { + }; + + template <> + struct is_pointer_select + { + template struct result_ + { + static T& make_t(); + BOOST_STATIC_CONSTANT(bool, value = + (1 == sizeof(is_pointer_tester(make_t()))) + ); + }; + }; + + template + struct is_pointer_impl + : is_pointer_select< + ::boost::type_traits::ice_or< + ::boost::is_reference::value + , ::boost::is_array::value + >::value + >::template result_ + { + }; + + template + struct is_pointer : is_pointer_impl + {}; + + template<> + struct is_pointer : ::boost::mpl::false_ + {}; +}}//namespace boost::type_of + +#endif //BOOST_TYPEOF_VINTAGE_IS_POINTER_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/modifier_array.hpp b/include/boost/typeof/vintage/modifier_array.hpp new file mode 100644 index 0000000..c54f02e --- /dev/null +++ b/include/boost/typeof/vintage/modifier_array.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +template<> +struct encode_impl +{ + template + struct encoder { + BOOST_STATIC_CONSTANT(unsigned,size=(sizeof(*((T*)NULL))/sizeof((*((T*)NULL))[0]))); + typedef void(*function_ptr)( + sizer, + typename mpl::next::type>::type + T, + Types + ); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + + friend sizer encode_value(const sizer&,const sizer&); + friend sizer encode_value(const sizer&,const sizer<(V::pos)+1>&); + }; +}; +template +typename encode_modifier::encoded_type encode(void(*)(sizer,V,T BOOST_TYPEOF_qualifier[],Types)); + +template<> +struct decode_impl +{ + template + struct decoder { + BOOST_STATIC_CONSTANT(unsigned,size=Iter::value); + typedef typename Iter::next iter1; + typedef typename decode_impl::decoder decode1; + typedef typename decode1::type BOOST_TYPEOF_qualifier type[size]; + typedef typename decode1::iter iter; + }; +}; diff --git a/include/boost/typeof/vintage/modifier_category.hpp b/include/boost/typeof/vintage/modifier_category.hpp new file mode 100644 index 0000000..7c7b4fe --- /dev/null +++ b/include/boost/typeof/vintage/modifier_category.hpp @@ -0,0 +1,121 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_MODIFIER_CATEGORY_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_MODIFIER_CATEGORY_HPP_INCLUDED + +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace type_of { + enum { + FUNCTION_OR_MEMBER_ID=BOOST_TYPEOF_UNIQUE_ID(), + VOID_ID, + NO_MODIFIERS, + CONST_ID, + VOLATILE_ID, + CV_ID, + POINTER_ID, + CONST_POINTER_ID, + VOLATILE_POINTER_ID, + CV_POINTER_ID, + REFERENCE_ID, + CONST_REFERENCE_ID, + VOLATILE_REFERENCE_ID, + CV_REFERENCE_ID, + ARRAY_ID, + CONST_ARRAY_ID, + VOLATILE_ARRAY_ID, + CV_ARRAY_ID, + MEMBER_POINTER_ID, + }; + +template +struct cv_type { + BOOST_STATIC_CONSTANT(unsigned,value=(N+is_const::value+is_volatile::value*2)); +}; + +template +struct indirection { + template + struct inner { + BOOST_STATIC_CONSTANT(unsigned,value=Indirection); + }; +}; + +template<>//pointer +struct indirection { + template + struct inner { + template + static char (*test(U*))[cv_type::value]; + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test((T)NULL) )); + }; +}; + +template<>//reference +struct indirection { + template + struct inner { + static T (*function)(); + + template + static char (*test(U& (*)()))[cv_type::value]; + + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test(function))); + }; +}; + +template<>//array +struct indirection { + template + struct inner { + template + static char (*test(U []))[cv_type::value]; + + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test(*((T*)NULL)) )); + }; +}; + +template +struct modifier_category { + template + struct inner { + BOOST_STATIC_CONSTANT(unsigned,value=NO_MODIFIERS+cv); + }; + template<> + struct inner<0> { + BOOST_STATIC_CONSTANT(int,indir= ( + //boost::is_function::value?FUNCTION_OR_MEMBER_ID: + boost::is_array::value?ARRAY_ID: + boost::type_of::is_pointer::value?POINTER_ID: + boost::is_reference::value?REFERENCE_ID: + NO_MODIFIERS + )); + BOOST_STATIC_CONSTANT(unsigned,value=indirection::inner::value); + }; + + BOOST_STATIC_CONSTANT(unsigned,cv=boost::is_array::value?0:boost::is_const::value+boost::is_volatile::value*2); + BOOST_STATIC_CONSTANT(unsigned,value=inner::value); +}; + +template<> +struct modifier_category +{ + BOOST_STATIC_CONSTANT(unsigned,value=VOID_ID); +}; + +}} //namespace boost::type_of + +#endif //BOOST_TYPEOF_VINTAGE_MODIFIER_CATEGORY_HPP_INCLUDED + diff --git a/include/boost/typeof/vintage/modifier_pointer.hpp b/include/boost/typeof/vintage/modifier_pointer.hpp new file mode 100644 index 0000000..1d8cf2e --- /dev/null +++ b/include/boost/typeof/vintage/modifier_pointer.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +template<> +struct encode_impl +{ + template + struct encoder { + typedef void(*function_ptr)( + sizer, + typename mpl::next::type, + T, + Types + ); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_modifier::encoded_type encode(void(*)(sizer,V,T BOOST_TYPEOF_qualifier *,Types)); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef typename decode_impl::decoder decode0; + typedef typename decode0::type BOOST_TYPEOF_qualifier * type; + typedef typename decode0::iter iter; + }; +}; diff --git a/include/boost/typeof/vintage/modifier_qualifier.hpp b/include/boost/typeof/vintage/modifier_qualifier.hpp new file mode 100644 index 0000000..4fb887b --- /dev/null +++ b/include/boost/typeof/vintage/modifier_qualifier.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +template<> +struct encode_impl +{ + template + struct encoder { + typedef void(*function_ptr)( + sizer, + typename mpl::next::type, + T*, + Types + ); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_modifier::encoded_type encode(void(*)(sizer,V,T BOOST_TYPEOF_qualifier *,Types)); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef typename decode_impl::decoder decode0; + typedef typename decode0::type BOOST_TYPEOF_qualifier type; + typedef typename decode0::iter iter; + }; +}; diff --git a/include/boost/typeof/vintage/modifier_reference.hpp b/include/boost/typeof/vintage/modifier_reference.hpp new file mode 100644 index 0000000..5deb68f --- /dev/null +++ b/include/boost/typeof/vintage/modifier_reference.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +template<> +struct encode_impl +{ + template + struct encoder { + typedef T(*function_ptr)( + sizer, + typename mpl::next::type, + Types + ); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_modifier::encoded_type encode(T BOOST_TYPEOF_qualifier& (*)(sizer,V,Types)); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef typename decode_impl::decoder decode0; + typedef typename decode0::type BOOST_TYPEOF_qualifier & type; + typedef typename decode0::iter iter; + }; +}; diff --git a/include/boost/typeof/vintage/modifiers.hpp b/include/boost/typeof/vintage/modifiers.hpp new file mode 100644 index 0000000..7247bb9 --- /dev/null +++ b/include/boost/typeof/vintage/modifiers.hpp @@ -0,0 +1,117 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_VINTAGE_TYPEOF_MODIFIERS_HPP_INCLUDED +#define BOOST_VINTAGE_TYPEOF_MODIFIERS_HPP_INCLUDED + +#include +#include +#include + +namespace boost { namespace type_of { + +sizer<0xffff> encode(...); +template +struct validate_type { + template + struct use_BOOST_TYPEOF_REGISTER_TYPE { + typedef int type; + }; +}; + +template<> +struct validate_type<0xffff> { + template + struct use_BOOST_TYPEOF_REGISTER_TYPE { + }; +}; + +template<> +struct encode_impl +{ + template + struct encoder { + typedef T const& (*function_ptr)(V,Types); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + //If T is a template type, use BOOST_TYPEOF_REGISTER_TEMPLATE. + typedef validate_type::use_BOOST_TYPEOF_REGISTER_TYPE::type type_validation; + }; +}; + +template<> +struct encode_impl +{ + template + struct encoder { + typedef T& (*function_ptr)(V,Types); + BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL)))); + }; +}; + +template<> +struct encode_impl +{ + template + struct encoder { + BOOST_STATIC_CONSTANT(unsigned,value= + sizeof( + typename encode_modifier< + typename mpl::next::type, + typename Types::type, + typename Types::next + >::encoded_type + ) + ); + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template<> +struct decode_impl +{ + template + struct decoder { + typedef void type; + typedef Iter iter; + }; +}; + +#define BOOST_TYPEOF_qualifier +#define n 0 +#include +#include +#include +#undef n +#undef BOOST_TYPEOF_qualifier + +#define BOOST_TYPEOF_qualifier const +#define n 1 +#include +#include +#include +#include +#undef n +#undef BOOST_TYPEOF_qualifier + +#define BOOST_TYPEOF_qualifier volatile +#define n 2 +#include +#include +#include +#include +#undef n +#undef BOOST_TYPEOF_qualifier + +#define BOOST_TYPEOF_qualifier const volatile +#define n 3 +#include +#include +#include +#include +#undef n +#undef BOOST_TYPEOF_qualifier + +}} //namespace boost::type_of + +#endif //BOOST_VINTAGE_TYPEOF_MODIFIERS_HPP_INCLUDED \ No newline at end of file diff --git a/include/boost/typeof/vintage/pointers_data_members.hpp b/include/boost/typeof/vintage/pointers_data_members.hpp new file mode 100644 index 0000000..a392bd4 --- /dev/null +++ b/include/boost/typeof/vintage/pointers_data_members.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_POINTERS_DATA_MEMBERS_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_POINTERS_DATA_MEMBERS_HPP_INCLUDED + +#include +#include + +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +namespace boost { namespace type_of{ + enum {PTR_DATA_MEM_ID = BOOST_TYPEOF_UNIQUE_ID()}; + + template<> + struct encode_impl + { + template + struct encoder { + typedef Types types_2; + typedef type_list< T, types_2 > types_1; + typedef type_list< R, types_1 > types_0; + BOOST_STATIC_CONSTANT(unsigned,value= + sizeof( + typename encode_modifier< + typename mpl::next::type, + typename types_0::type, + types_1 + >::encoded_type + ) + ); + friend sizer encode_value(const sizer&,const sizer&); + }; + }; + template + typename encode_impl::template encoder + encode(R (T::* const&(*function)(V,Types))); + + template<> struct decode_impl { + template + struct decoder { + typedef Iter iter0; + BOOST_TYPEOF_DECODE_PARAMS(2) + + template struct workaround{ + typedef R (T::*type); + }; + template<> struct workaround{ + typedef int type; + }; + + typedef workaround::type type; + typedef iter2 iter; + }; + }; +}} //namespace boost::type_of + +#endif //BOOST_TYPEOF_REGISTER_MEMBER_POINTER_HPP_HOLT_2004_1015 \ No newline at end of file diff --git a/include/boost/typeof/vintage/preserve_lvalue.hpp b/include/boost/typeof/vintage/preserve_lvalue.hpp new file mode 100644 index 0000000..252c45f --- /dev/null +++ b/include/boost/typeof/vintage/preserve_lvalue.hpp @@ -0,0 +1,69 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_VINTAGE_PRESERVE_LVALUE_HPP_INCLUDED +#define BOOST_VINTAGE_PRESERVE_LVALUE_HPP_INCLUDED + +#include + +namespace boost +{ + namespace type_of + { + enum + { + RVALUE = 1, + LVALUE, + CONST_LVALUE + }; + + char(*classify_expression(...))[ + RVALUE + ]; + + template + char(*classify_expression(T&))[ + is_const::value ? CONST_LVALUE : LVALUE + ]; + template + struct decorate_type_impl { + template + struct inner { + typedef T type; + }; + }; + template<> + struct decorate_type_impl { + template + struct inner { + typedef T& type; + }; + }; + + template<> + struct decorate_type_impl { + template + struct inner { + typedef T const& type; + }; + }; + + template struct decorate_type + { + typedef decorate_type_impl::inner::type type; + }; + } +} + +// Since this is always a type, +// just add "typename" when using in templates + +#define BOOST_TYPEOF_PRESERVE_LVALUE(expr) \ + boost::type_of::decorate_type< \ + BOOST_TYPEOF(expr), \ + sizeof(*boost::type_of::classify_expression(expr)) \ + >::type + + +#endif //BOOST_VINTAGE_PRESERVE_LVALUE_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/register_functions_iterate.hpp b/include/boost/typeof/vintage/register_functions_iterate.hpp new file mode 100644 index 0000000..29baf84 --- /dev/null +++ b/include/boost/typeof/vintage/register_functions_iterate.hpp @@ -0,0 +1,105 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#define n BOOST_PP_ITERATION() + +template<> +struct encode_impl +{ + template + struct encoder { + typedef Types BOOST_PP_CAT(types_,n); + BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n) + BOOST_STATIC_CONSTANT(int,instantiate = + sizeof( + encode_modifier< + mpl::next::type, + R, + types_0 + >::encoded_type + ) + ); + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_impl::template encoder +encode(R (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) ); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef Iter iterR; + typedef decode_impl::decoder decodeR; + 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 BOOST_PP_CAT(iter,n) iter; + }; +}; + +template<> +struct encode_impl +{ + template + struct encoder { + typedef Types BOOST_PP_CAT(types_,n); + BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n) + BOOST_STATIC_CONSTANT(int,instantiate = + sizeof( + encode_modifier< + mpl::next::type, + R, + types_0 + >::encoded_type + ) + ); + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_impl::template encoder +encode(R (* const& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) ); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef Iter iterR; + typedef decode_impl::decoder decodeR; + 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 BOOST_PP_CAT(iter,n) iter; + }; +}; + +#define BOOST_TYPEOF_qualifier +#define BOOST_TYPEOF_id MEM_FUN_ID + +#include + +#define BOOST_TYPEOF_qualifier const +#define BOOST_TYPEOF_id CONST_MEM_FUN_ID + +#include + +#define BOOST_TYPEOF_qualifier volatile +#define BOOST_TYPEOF_id VOLATILE_MEM_FUN_ID + +#include + +#define BOOST_TYPEOF_qualifier volatile const +#define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID + +#include + +#undef n \ No newline at end of file diff --git a/include/boost/typeof/vintage/register_mem_functions.hpp b/include/boost/typeof/vintage/register_mem_functions.hpp new file mode 100644 index 0000000..bd83e76 --- /dev/null +++ b/include/boost/typeof/vintage/register_mem_functions.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2004 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +//member functions +//This file must not be included directly. + +template<> +struct encode_impl +{ + template + struct encoder { + typedef Types BOOST_PP_CAT(types_,n); + BOOST_PP_REPEAT(n,BOOST_TYPEOF_PUSH_FRONT,n) + BOOST_STATIC_CONSTANT(int,instantiate = + sizeof( + encode_modifier< + mpl::next::type, + R, + type_list + >::encoded_type + ) + ); + friend sizer encode_value(const sizer&,const sizer&); + }; +}; + +template +typename encode_impl::template encoder +encode(R (T::* const&(*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) BOOST_TYPEOF_qualifier); + +template<> +struct decode_impl +{ + template + struct decoder { + typedef Iter iterR; + typedef decode_impl::decoder decodeR;\ + typedef typename decodeR::type R; + typedef typename decodeR::iter iterT; + typedef decode_impl::decoder decodeT;\ + typedef typename decodeT::type T; + typedef typename decodeT::iter iter0; + BOOST_TYPEOF_DECODE_PARAMS(n) + template + struct workaround { + typedef R_ (T_::*type)(BOOST_PP_ENUM_PARAMS(n,A_)) BOOST_TYPEOF_qualifier; + }; + template<> + struct workaround { + typedef int type; + }; + typedef workaround::type type; + typedef BOOST_PP_CAT(iter,n) iter; + }; +}; + +#undef BOOST_TYPEOF_id +#undef BOOST_TYPEOF_qualifier diff --git a/include/boost/typeof/vintage/sizer.hpp b/include/boost/typeof/vintage/sizer.hpp new file mode 100644 index 0000000..dbbde34 --- /dev/null +++ b/include/boost/typeof/vintage/sizer.hpp @@ -0,0 +1,101 @@ +// Copyright (C) 2004 Peder Holt +// 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_SIZER_HPP_HOLT_2004_0819 +#define BOOST_TYPEOF_SIZER_HPP_HOLT_2004_0819 + +#ifdef BOOST_MAX_RECURSION +#include +#include +#endif + +namespace boost{namespace type_of { + +/* +The reason for a sizer class to extract the size of a type from, +is that using the size of a function returning an array limits the size of the array to 0x7FFFFFF +(At least on VC 6.5) This is ok when representing type identifiers, +but not when representing integral types such as mpl::int_<0xFFFFFFFF>. +Also, VC 7.0 does not do well with function references returning an array ( char (&f())[N];) +sizer can be used to represent any number from 1 to 0xFFFFFFFF. +*/ +template +struct sizer { + enum {value1=S/2}; + enum {value2=S-S/2}; + char a[value1]; + char b[value2]; +}; + +template<> +struct sizer<1> { + char type; +}; + +template<> +struct sizer<0xFFFFFFFF> { + char a[0x7FFFFFFF]; + char b[0x7FFFFFFF]; + char c; +}; + +template<> +struct sizer<0> { + //Unable to represent a type with zero size. +}; + +template struct encode_counter : encode_counter {}; +template<> struct encode_counter<0> {}; + +#ifdef BOOST_MAX_RECURSION +#define BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER(z,n,text)\ +template<> struct encode_counter {}; + +BOOST_PP_REPEAT(20,BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER,_) +#undef BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER + + +template +struct counter_start +{ + template + struct increase_limit { + BOOST_STATIC_CONSTANT(unsigned,value=(counter_start::value)); + }; + template<> + struct increase_limit + { + BOOST_STATIC_CONSTANT(unsigned,value=N-1); + }; + BOOST_STATIC_CONSTANT(unsigned,current=N-1); + BOOST_STATIC_CONSTANT(unsigned,next=N+BOOST_MAX_RECURSION-1); + + BOOST_STATIC_CONSTANT(bool,exceed_current=(sizeof(encode_index((encode_counter*)NULL))==current)); + BOOST_STATIC_CONSTANT(bool,start_next=(sizeof(encode_index((encode_counter*)NULL))>1)); + BOOST_STATIC_CONSTANT(unsigned,value=(increase_limit::value)); + typedef encode_counter type; +}; + +#define BOOST_TYPEOF_INDEX(T) (sizeof(boost::type_of::encode_index((boost::type_of::counter_start::type*)0))) +#else + +#define BOOST_TYPEOF_INDEX(T) (sizeof(boost::type_of::encode_index((boost::type_of::encode_counter*)0))) + +#endif + +#define BOOST_TYPEOF_VALUE(A,B) (sizeof(boost::type_of::encode_value(A(),B()))) + + +sizer<1> encode_value(...); +//Need a large starting value, due to MSVC's ETI errors. +sizer encode_index(...); +/* +#define BOOST_TYPEOF_VALUE(N) (sizeof(boost::type_of::encode_value((boost::type_of::encode_counter*)0))) +#define BOOST_TYPEOF_INDEX() (sizeof(*boost::type_of::encode_index((boost::type_of::encode_counter*)0))) +*/ + +}}//namespace boost::type_of + +#endif //BOOST_TYPEOF_SIZER_HPP_HOLT_2004_0819 + diff --git a/include/boost/typeof/vintage/template_encoding.hpp b/include/boost/typeof/vintage/template_encoding.hpp new file mode 100644 index 0000000..fc72e21 --- /dev/null +++ b/include/boost/typeof/vintage/template_encoding.hpp @@ -0,0 +1,89 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_TEMPLATE_ENCODING_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_TEMPLATE_ENCODING_HPP_INCLUDED + +#include +#include +#include +#include +#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() + +//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_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_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_ENCODE_SEQ(z,n,seq)\ + BOOST_PP_SEQ_ELEM(n, seq) BOOST_PP_CAT(A,n) + +#define BOOST_TYPEOF_STORE_TYPE_START(z,n,seq) type_list BOOST_PP_EMPTY() + +#define BOOST_TYPEOF_ENCODE_TEMPLATE(template_type,seq)\ + template<>\ + struct encode_impl\ + {\ + 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))\ + 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&);\ + };\ + };\ + template\ + typename encode_impl::encoder encode(template_type const& (*)(V,Types)); + +#define BOOST_TYPEOF_DECODE_TEMPLATE(template_type,seq)\ + template<>\ + 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;\ + };\ + }; + +#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)\ +}}//namespace boost::type_of + +#define BOOST_TYPEOF_REGISTER_TEMPLATE_TYPE_PARAM_(z, n, data) (typename) + +#define BOOST_TYPEOF_REGISTER_TEMPLATE(template_type, n)\ + BOOST_TYPEOF_REGISTER_TEMPLATE_X(template_type,\ + BOOST_PP_REPEAT(n, BOOST_TYPEOF_REGISTER_TEMPLATE_TYPE_PARAM_, ~)\ + ) + +#endif //BOOST_VINTAGE_TEMPLATE_ENCODING_HPP_INCLUDED diff --git a/include/boost/typeof/vintage/type_encoding.hpp b/include/boost/typeof/vintage/type_encoding.hpp new file mode 100644 index 0000000..cf5ce8d --- /dev/null +++ b/include/boost/typeof/vintage/type_encoding.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_TYPE_ENCODING_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_TYPE_ENCODING_HPP_INCLUDED + +#include + +#define BOOST_TYPEOF_ENCODE_TYPE(simple_type)\ + template<>\ + struct encode_impl\ + {\ + template\ + struct encoder {\ + BOOST_STATIC_CONSTANT(unsigned,value=\ + sizeof(\ + typename encode_modifier<\ + typename mpl::next::type,\ + typename Types::type,\ + typename Types::next\ + >::encoded_type\ + )\ + );\ + friend sizer encode_value(const sizer&,const sizer&);\ + };\ + };\ + template\ + typename encode_impl::encoder encode(simple_type const& (*)(V,Types)); + +#define BOOST_TYPEOF_DECODE_TYPE(simple_type)\ + template<>\ + struct decode_impl\ + {\ + template\ + struct decoder {\ + typedef simple_type type;\ + typedef Iter iter;\ + };\ + };\ + +#define BOOST_TYPEOF_REGISTER_TYPE(simple_type)\ +namespace boost { namespace type_of{\ +BOOST_TYPEOF_ENCODE_TYPE(simple_type)\ +BOOST_TYPEOF_DECODE_TYPE(simple_type)\ +}}//namespace boost::type_of + +#endif //BOOST_TYPEOF_VINTAGE_TYPE_ENCODING_HPP_INCLUDED \ No newline at end of file diff --git a/include/boost/typeof/vintage/type_list.hpp b/include/boost/typeof/vintage/type_list.hpp new file mode 100644 index 0000000..3765648 --- /dev/null +++ b/include/boost/typeof/vintage/type_list.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_TYPE_LIST_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_TYPE_LIST_HPP_INCLUDED + +namespace boost{ namespace type_of{ + struct empty_type_list { + typedef empty_type_list type; + typedef empty_type_list next; + }; + template + struct type_list { + typedef T type; + typedef Next next; + }; + + template + int + encode(empty_type_list const& (*)(V,Types)); + +}}//namespace boost::type_of + +#endif //BOOST_TYPEOF_VINTAGE_TYPE_LIST_HPP_INCLUDED + diff --git a/include/boost/typeof/vintage/type_to_macro.hpp b/include/boost/typeof/vintage/type_to_macro.hpp new file mode 100644 index 0000000..5eef057 --- /dev/null +++ b/include/boost/typeof/vintage/type_to_macro.hpp @@ -0,0 +1,68 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_TYPE_TO_MACRO_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_TYPE_TO_MACRO_HPP_INCLUDED + +#include +#include +#include + +/* +These macros are used to dechifer template arguments into sensible macros. +There are three predefined macro builders: +BOOST_TYPEOF_typename - for class and typename arguments +BOOST_TYPEOF_integral - for signed integral values, int,short,char,bool, etc. +BOOST_TYPEOF_unsigned_integral - for unsigned integral values, unsigned, unsigned long etc. + +All the fundamental integral types (except long long) have been pre-registered. +In order to implement new template argument types (enums), +you need to define a macro containing the name of the enum: + +enum MyEnum {red=0,green=1,blue=2}; +#define BOOST_TYPEOF__MyEnum__ BOOST_TYPEOF_integral + +//MyEnum is now treated as an integral value in template expressions. + +template +struct enum_class {}; + +//Is registered using +BOOST_TYPEOF_DEFINE_TEMPLATE(enum_class,1,(MyEnum)) +*/ + +#define BOOST_TYPEOF_typename(dummy,append,arg) BOOST_PP_CAT(BOOST_TYPEOF_typename_,append)arg +#define BOOST_TYPEOF_integral(dummy,append,arg) BOOST_PP_CAT(BOOST_TYPEOF_integral_,append)arg +#define BOOST_TYPEOF_unsigned_integral(dummy,append,arg) BOOST_PP_CAT(BOOST_TYPEOF_unsigned_integral_,append)arg + +#define BOOST_TYPEOF__typename__ BOOST_TYPEOF_typename BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__class__ BOOST_TYPEOF_typename BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__bool__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__char__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__short__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__int__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__long__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__unsigned__ BOOST_TYPEOF_unsigned_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__signed__ BOOST_TYPEOF_integral BOOST_PP_LPAREN() dummy +#define BOOST_TYPEOF__unsigned BOOST_TYPEOF_unsigned_integral BOOST_PP_LPAREN() +#define BOOST_TYPEOF__signed BOOST_TYPEOF_integral BOOST_PP_LPAREN() + + +#define BOOST_TYPEOF_WRAP2(expr) expr +#define BOOST_TYPEOF_WRAP1(expr) BOOST_TYPEOF_WRAP2 expr + +#define BOOST_TYPEOF_ENCODE_ARGUMENT(z,n,text)\ + BOOST_TYPEOF_WRAP1((BOOST_PP_CAT(BOOST_TYPEOF__,BOOST_PP_CAT(text,__)),encode,(BOOST_PP_CAT(A,n)) BOOST_PP_RPAREN())) + +#define BOOST_TYPEOF_ENCODE_SEQ_ELEMENT(z,n,seq)\ + BOOST_TYPEOF_ENCODE_ARGUMENT(z,n,BOOST_PP_SEQ_ELEM(n, seq)) + +#define BOOST_TYPEOF_DECODE_ARGUMENT(z,n,text)\ + BOOST_TYPEOF_WRAP1((BOOST_PP_CAT(BOOST_TYPEOF__,BOOST_PP_CAT(text,__)),decode,(n,text) BOOST_PP_RPAREN())) + +#define BOOST_TYPEOF_DECODE_SEQ_ELEMENT(z,n,seq)\ + BOOST_TYPEOF_DECODE_ARGUMENT(z,n,BOOST_PP_SEQ_ELEM(n, seq)) + +#endif //BOOST_VINTAGE_TYPE_TO_MACRO_HPP_INCLUDED + diff --git a/include/boost/typeof/vintage/typeof_impl.hpp b/include/boost/typeof/vintage/typeof_impl.hpp new file mode 100644 index 0000000..cdd66bb --- /dev/null +++ b/include/boost/typeof/vintage/typeof_impl.hpp @@ -0,0 +1,61 @@ +// Copyright (C) 2004 Peder Holt +// 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_VINTAGE_TYPEOF_IMPL_HPP_INCLUDED +#define BOOST_TYPEOF_VINTAGE_TYPEOF_IMPL_HPP_INCLUDED + +#include +#include +namespace boost +{ + namespace type_of + { + template + struct iterator { + BOOST_STATIC_CONSTANT(unsigned,index=Index); + BOOST_STATIC_CONSTANT(unsigned,pos=Position); + typedef iterator next; + }; + + template + struct encode_type + { + BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T)); + BOOST_STATIC_CONSTANT(unsigned,encode_dummy=sizeof(BOOST_DEDUCED_TYPENAME encode_modifier,T,empty_type_list>::encoded_type)); + + BOOST_STATIC_CONSTANT(unsigned,next=value+1); + friend sizer encode_index(encode_counter*); + + sizer resize; + }; + + template + encode_type encode_start(T const&); + + template + struct decode { + typedef typename decode_impl::decoder::type type; + }; + template<> + struct decode { + typedef int type; + }; + template + struct value_iterator { + BOOST_STATIC_CONSTANT(unsigned,pos=Position); + BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_VALUE(sizer,sizer)); + typedef value_iterator next; + }; + } +} + +#define BOOST_TYPEOF(expr) \ + boost::type_of::decode >::type + +#define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr) + + +#endif//BOOST_TYPEOF_VINTAGE_TYPEOF_IMPL_HPP_INCLUDED + +