forked from boostorg/typeof
Added vintage typeof support for MSVC 6.5 and VC 7.0
[SVN r2335]
This commit is contained in:
32
include/boost/typeof/vintage/concatenate.hpp
Normal file
32
include/boost/typeof/vintage/concatenate.hpp
Normal file
@ -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 <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#include <boost/typeof/vintage/type_list.hpp>
|
||||
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
// Assumes iter0 contains initial iterator
|
||||
|
||||
#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::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
|
74
include/boost/typeof/vintage/config.hpp
Normal file
74
include/boost/typeof/vintage/config.hpp
Normal file
@ -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 <boost/preprocessor/cat.hpp>
|
||||
|
||||
#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 <typename T> \
|
||||
struct BOOST_PP_CAT(get_, name) \
|
||||
{ \
|
||||
typedef typename T::name type; \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct BOOST_PP_CAT(get_, name)<int> \
|
||||
{ \
|
||||
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<T>::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 <typename T>
|
||||
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<int>
|
||||
{
|
||||
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<T>::value
|
||||
#else
|
||||
# define TYPEOF_GET_VALUE(T) T::value
|
||||
#endif
|
||||
|
||||
#endif //BOOST_TYPEOF_VINTAGE_CONFIG_HPP_INCLUDED
|
50
include/boost/typeof/vintage/encode_decode.hpp
Normal file
50
include/boost/typeof/vintage/encode_decode.hpp
Normal file
@ -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()\
|
||||
<boost/typeof/increment_registration_group.hpp>
|
||||
|
||||
#include <boost/typeof/vintage/modifier_category.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
template<unsigned N>
|
||||
struct encode_impl {
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
};
|
||||
};
|
||||
template<int>
|
||||
struct decode_impl{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef int type;
|
||||
typedef int iter;
|
||||
};
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
template<>
|
||||
struct decoder<int> {
|
||||
typedef int type;
|
||||
typedef int iter;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encode_modifier {
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=modifier_category<T>::value);
|
||||
typedef typename encode_impl<value>::template encoder<V,T,Types> encoded_type;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_VINTAGE_ENCODE_DECODE_HPP_INCLUDED
|
167
include/boost/typeof/vintage/int_encoding.hpp
Normal file
167
include/boost/typeof/vintage/int_encoding.hpp
Normal file
@ -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 <boost/config.hpp>
|
||||
|
||||
namespace boost {namespace type_of {
|
||||
|
||||
template<unsigned N>
|
||||
struct encode_integral_wrapper {};
|
||||
|
||||
template<unsigned N>
|
||||
struct encode_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^0x80000000> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
//Special implementation for 0x80000000 and 0x7FFFFFFF in order to allow representation of all numbers
|
||||
template<>
|
||||
struct encode_integral<0x80000000>
|
||||
{
|
||||
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<0x80000000> encode_value(const sizer<V::index>&,const sizer<(V::pos)+1>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct encode_integral<0x7FFFFFFF>
|
||||
{
|
||||
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<0x7FFFFFFF> encode_value(const sizer<V::index>&,const sizer<(V::pos)+1>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<unsigned N,typename V,typename Types>
|
||||
typename encode_integral<N>::encoder<V,Types> encode(encode_integral_wrapper<N> const&(*)(V,Types));
|
||||
|
||||
template<unsigned N>
|
||||
struct decode_integral_base {
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
BOOST_STATIC_CONSTANT(int,value=N^0x80000000);
|
||||
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_integral_base<0xFFFFFFFF> {
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
BOOST_STATIC_CONSTANT(int,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_integral : decode_integral_base<TYPEOF_GET_VALUE(Iter)>::decoder<TYPEOF_GET_NEXT(Iter)>
|
||||
{
|
||||
};
|
||||
|
||||
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
|
54
include/boost/typeof/vintage/is_pointer.hpp
Normal file
54
include/boost/typeof/vintage/is_pointer.hpp
Normal file
@ -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 <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
template<typename T>
|
||||
boost::detail::yes_type is_pointer_tester(T*);
|
||||
boost::detail::no_type is_pointer_tester(...);
|
||||
|
||||
template <bool>
|
||||
struct is_pointer_select
|
||||
: ::boost::type_traits::false_result
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_pointer_select<false>
|
||||
{
|
||||
template <typename T> struct result_
|
||||
{
|
||||
static T& make_t();
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(1 == sizeof(is_pointer_tester(make_t())))
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer_impl
|
||||
: is_pointer_select<
|
||||
::boost::type_traits::ice_or<
|
||||
::boost::is_reference<T>::value
|
||||
, ::boost::is_array<T>::value
|
||||
>::value
|
||||
>::template result_<T>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_pointer : is_pointer_impl<T>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct is_pointer<void> : ::boost::mpl::false_
|
||||
{};
|
||||
}}//namespace boost::type_of
|
||||
|
||||
#endif //BOOST_TYPEOF_VINTAGE_IS_POINTER_HPP_INCLUDED
|
37
include/boost/typeof/vintage/modifier_array.hpp
Normal file
37
include/boost/typeof/vintage/modifier_array.hpp
Normal file
@ -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<ARRAY_ID+n>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
BOOST_STATIC_CONSTANT(unsigned,size=(sizeof(*((T*)NULL))/sizeof((*((T*)NULL))[0])));
|
||||
typedef void(*function_ptr)(
|
||||
sizer<ARRAY_ID+n>,
|
||||
typename mpl::next<typename mpl::next<V>::type>::type
|
||||
T,
|
||||
Types
|
||||
);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL))));
|
||||
|
||||
friend sizer<ARRAY_ID+n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
friend sizer<size> encode_value(const sizer<V::index>&,const sizer<(V::pos)+1>&);
|
||||
};
|
||||
};
|
||||
template<typename V,typename T,typename Types>
|
||||
typename encode_modifier<V,T,Types>::encoded_type encode(void(*)(sizer<ARRAY_ID+n>,V,T BOOST_TYPEOF_qualifier[],Types));
|
||||
|
||||
template<>
|
||||
struct decode_impl<ARRAY_ID+n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
BOOST_STATIC_CONSTANT(unsigned,size=Iter::value);
|
||||
typedef typename Iter::next iter1;
|
||||
typedef typename decode_impl<iter1::value>::decoder<iter1::next> decode1;
|
||||
typedef typename decode1::type BOOST_TYPEOF_qualifier type[size];
|
||||
typedef typename decode1::iter iter;
|
||||
};
|
||||
};
|
121
include/boost/typeof/vintage/modifier_category.hpp
Normal file
121
include/boost/typeof/vintage/modifier_category.hpp
Normal file
@ -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 <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_volatile.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_member_pointer.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/typeof/vintage/is_pointer.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
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<typename U,int N>
|
||||
struct cv_type {
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=(N+is_const<U>::value+is_volatile<U>::value*2));
|
||||
};
|
||||
|
||||
template<int Indirection>
|
||||
struct indirection {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=Indirection);
|
||||
};
|
||||
};
|
||||
|
||||
template<>//pointer
|
||||
struct indirection<POINTER_ID> {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
template<typename U>
|
||||
static char (*test(U*))[cv_type<U,POINTER_ID>::value];
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test((T)NULL) ));
|
||||
};
|
||||
};
|
||||
|
||||
template<>//reference
|
||||
struct indirection<REFERENCE_ID> {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static T (*function)();
|
||||
|
||||
template<typename U>
|
||||
static char (*test(U& (*)()))[cv_type<U,REFERENCE_ID>::value];
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test(function)));
|
||||
};
|
||||
};
|
||||
|
||||
template<>//array
|
||||
struct indirection<ARRAY_ID> {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
template<typename U>
|
||||
static char (*test(U []))[cv_type<U,ARRAY_ID>::value];
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(*test(*((T*)NULL)) ));
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct modifier_category {
|
||||
template<int cv>
|
||||
struct inner {
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=NO_MODIFIERS+cv);
|
||||
};
|
||||
template<>
|
||||
struct inner<0> {
|
||||
BOOST_STATIC_CONSTANT(int,indir= (
|
||||
//boost::is_function<T>::value?FUNCTION_OR_MEMBER_ID:
|
||||
boost::is_array<T>::value?ARRAY_ID:
|
||||
boost::type_of::is_pointer<T>::value?POINTER_ID:
|
||||
boost::is_reference<T>::value?REFERENCE_ID:
|
||||
NO_MODIFIERS
|
||||
));
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=indirection<indir>::inner<T>::value);
|
||||
};
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned,cv=boost::is_array<T>::value?0:boost::is_const<T>::value+boost::is_volatile<T>::value*2);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=inner<cv>::value);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct modifier_category<void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=VOID_ID);
|
||||
};
|
||||
|
||||
}} //namespace boost::type_of
|
||||
|
||||
#endif //BOOST_TYPEOF_VINTAGE_MODIFIER_CATEGORY_HPP_INCLUDED
|
||||
|
34
include/boost/typeof/vintage/modifier_pointer.hpp
Normal file
34
include/boost/typeof/vintage/modifier_pointer.hpp
Normal file
@ -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<POINTER_ID+n>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
typedef void(*function_ptr)(
|
||||
sizer<POINTER_ID+n>,
|
||||
typename mpl::next<V>::type,
|
||||
T,
|
||||
Types
|
||||
);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL))));
|
||||
|
||||
friend sizer<POINTER_ID+n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<typename V,typename T,typename Types>
|
||||
typename encode_modifier<V,T,Types>::encoded_type encode(void(*)(sizer<POINTER_ID+n>,V,T BOOST_TYPEOF_qualifier *,Types));
|
||||
|
||||
template<>
|
||||
struct decode_impl<POINTER_ID+n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef typename decode_impl<Iter::value>::decoder<Iter::next> decode0;
|
||||
typedef typename decode0::type BOOST_TYPEOF_qualifier * type;
|
||||
typedef typename decode0::iter iter;
|
||||
};
|
||||
};
|
34
include/boost/typeof/vintage/modifier_qualifier.hpp
Normal file
34
include/boost/typeof/vintage/modifier_qualifier.hpp
Normal file
@ -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<NO_MODIFIERS+n>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
typedef void(*function_ptr)(
|
||||
sizer<NO_MODIFIERS+n>,
|
||||
typename mpl::next<V>::type,
|
||||
T*,
|
||||
Types
|
||||
);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL))));
|
||||
|
||||
friend sizer<NO_MODIFIERS+n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<typename V,typename T,typename Types>
|
||||
typename encode_modifier<V,T,Types>::encoded_type encode(void(*)(sizer<NO_MODIFIERS+n>,V,T BOOST_TYPEOF_qualifier *,Types));
|
||||
|
||||
template<>
|
||||
struct decode_impl<NO_MODIFIERS+n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef typename decode_impl<Iter::value>::decoder<Iter::next> decode0;
|
||||
typedef typename decode0::type BOOST_TYPEOF_qualifier type;
|
||||
typedef typename decode0::iter iter;
|
||||
};
|
||||
};
|
33
include/boost/typeof/vintage/modifier_reference.hpp
Normal file
33
include/boost/typeof/vintage/modifier_reference.hpp
Normal file
@ -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<REFERENCE_ID+n>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
typedef T(*function_ptr)(
|
||||
sizer<REFERENCE_ID+n>,
|
||||
typename mpl::next<V>::type,
|
||||
Types
|
||||
);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL))));
|
||||
|
||||
friend sizer<REFERENCE_ID+n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<typename V,typename T,typename Types>
|
||||
typename encode_modifier<V,T,Types>::encoded_type encode(T BOOST_TYPEOF_qualifier& (*)(sizer<REFERENCE_ID+n>,V,Types));
|
||||
|
||||
template<>
|
||||
struct decode_impl<REFERENCE_ID+n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef typename decode_impl<Iter::value>::decoder<Iter::next> decode0;
|
||||
typedef typename decode0::type BOOST_TYPEOF_qualifier & type;
|
||||
typedef typename decode0::iter iter;
|
||||
};
|
||||
};
|
117
include/boost/typeof/vintage/modifiers.hpp
Normal file
117
include/boost/typeof/vintage/modifiers.hpp
Normal file
@ -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 <boost/typeof/vintage/type_list.hpp>
|
||||
#include <boost/typeof/vintage/encode_decode.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
sizer<0xffff> encode(...);
|
||||
template<unsigned N>
|
||||
struct validate_type {
|
||||
template<typename T>
|
||||
struct use_BOOST_TYPEOF_REGISTER_TYPE {
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct validate_type<0xffff> {
|
||||
template<typename T>
|
||||
struct use_BOOST_TYPEOF_REGISTER_TYPE {
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct encode_impl<NO_MODIFIERS>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
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<value>::use_BOOST_TYPEOF_REGISTER_TYPE<T>::type type_validation;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct encode_impl<FUNCTION_OR_MEMBER_ID>
|
||||
{
|
||||
template<typename V,typename T,typename Types>
|
||||
struct encoder {
|
||||
typedef T& (*function_ptr)(V,Types);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=sizeof(encode(function_ptr(NULL))));
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct encode_impl<VOID_ID>
|
||||
{
|
||||
template<typename V,typename T,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<VOID_ID> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct decode_impl<VOID_ID>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef void type;
|
||||
typedef Iter iter;
|
||||
};
|
||||
};
|
||||
|
||||
#define BOOST_TYPEOF_qualifier
|
||||
#define n 0
|
||||
#include <boost/typeof/vintage/modifier_pointer.hpp>
|
||||
#include <boost/typeof/vintage/modifier_reference.hpp>
|
||||
#include <boost/typeof/vintage/modifier_array.hpp>
|
||||
#undef n
|
||||
#undef BOOST_TYPEOF_qualifier
|
||||
|
||||
#define BOOST_TYPEOF_qualifier const
|
||||
#define n 1
|
||||
#include <boost/typeof/vintage/modifier_qualifier.hpp>
|
||||
#include <boost/typeof/vintage/modifier_pointer.hpp>
|
||||
#include <boost/typeof/vintage/modifier_reference.hpp>
|
||||
#include <boost/typeof/vintage/modifier_array.hpp>
|
||||
#undef n
|
||||
#undef BOOST_TYPEOF_qualifier
|
||||
|
||||
#define BOOST_TYPEOF_qualifier volatile
|
||||
#define n 2
|
||||
#include <boost/typeof/vintage/modifier_qualifier.hpp>
|
||||
#include <boost/typeof/vintage/modifier_pointer.hpp>
|
||||
#include <boost/typeof/vintage/modifier_reference.hpp>
|
||||
#include <boost/typeof/vintage/modifier_array.hpp>
|
||||
#undef n
|
||||
#undef BOOST_TYPEOF_qualifier
|
||||
|
||||
#define BOOST_TYPEOF_qualifier const volatile
|
||||
#define n 3
|
||||
#include <boost/typeof/vintage/modifier_qualifier.hpp>
|
||||
#include <boost/typeof/vintage/modifier_pointer.hpp>
|
||||
#include <boost/typeof/vintage/modifier_reference.hpp>
|
||||
#include <boost/typeof/vintage/modifier_array.hpp>
|
||||
#undef n
|
||||
#undef BOOST_TYPEOF_qualifier
|
||||
|
||||
}} //namespace boost::type_of
|
||||
|
||||
#endif //BOOST_VINTAGE_TYPEOF_MODIFIERS_HPP_INCLUDED
|
59
include/boost/typeof/vintage/pointers_data_members.hpp
Normal file
59
include/boost/typeof/vintage/pointers_data_members.hpp
Normal file
@ -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 <boost/typeof/config.hpp>
|
||||
#include <boost/typeof/vintage/concatenate.hpp>
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
namespace boost { namespace type_of{
|
||||
enum {PTR_DATA_MEM_ID = BOOST_TYPEOF_UNIQUE_ID()};
|
||||
|
||||
template<>
|
||||
struct encode_impl<PTR_DATA_MEM_ID>
|
||||
{
|
||||
template<typename V,typename R,typename T,typename Types>
|
||||
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<V>::type,
|
||||
typename types_0::type,
|
||||
types_1
|
||||
>::encoded_type
|
||||
)
|
||||
);
|
||||
friend sizer<PTR_DATA_MEM_ID> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
template<typename R,typename T,typename V,typename Types>
|
||||
typename encode_impl<PTR_DATA_MEM_ID>::template encoder<V,R,T,Types>
|
||||
encode(R (T::* const&(*function)(V,Types)));
|
||||
|
||||
template<> struct decode_impl<PTR_DATA_MEM_ID> {
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef Iter iter0;
|
||||
BOOST_TYPEOF_DECODE_PARAMS(2)
|
||||
|
||||
template<typename R,typename T> struct workaround{
|
||||
typedef R (T::*type);
|
||||
};
|
||||
template<> struct workaround<int,int>{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
typedef workaround<A0,A1>::type type;
|
||||
typedef iter2 iter;
|
||||
};
|
||||
};
|
||||
}} //namespace boost::type_of
|
||||
|
||||
#endif //BOOST_TYPEOF_REGISTER_MEMBER_POINTER_HPP_HOLT_2004_1015
|
69
include/boost/typeof/vintage/preserve_lvalue.hpp
Normal file
69
include/boost/typeof/vintage/preserve_lvalue.hpp
Normal file
@ -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 <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
enum
|
||||
{
|
||||
RVALUE = 1,
|
||||
LVALUE,
|
||||
CONST_LVALUE
|
||||
};
|
||||
|
||||
char(*classify_expression(...))[
|
||||
RVALUE
|
||||
];
|
||||
|
||||
template<class T>
|
||||
char(*classify_expression(T&))[
|
||||
is_const<T>::value ? CONST_LVALUE : LVALUE
|
||||
];
|
||||
template<int n>
|
||||
struct decorate_type_impl {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
typedef T type;
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct decorate_type_impl<LVALUE> {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
typedef T& type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct decorate_type_impl<CONST_LVALUE> {
|
||||
template<typename T>
|
||||
struct inner {
|
||||
typedef T const& type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T, int n> struct decorate_type
|
||||
{
|
||||
typedef decorate_type_impl<n>::inner<T>::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
|
105
include/boost/typeof/vintage/register_functions_iterate.hpp
Normal file
105
include/boost/typeof/vintage/register_functions_iterate.hpp
Normal file
@ -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<FUN_ID + n>
|
||||
{
|
||||
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
|
||||
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<V>::type,
|
||||
R,
|
||||
types_0
|
||||
>::encoded_type
|
||||
)
|
||||
);
|
||||
friend sizer<FUN_ID + n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
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 (& (*function)(V,Types))(BOOST_PP_ENUM_PARAMS(n,A)) );
|
||||
|
||||
template<>
|
||||
struct decode_impl<FUN_ID + n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef Iter iterR;
|
||||
typedef decode_impl<TYPEOF_GET_VALUE(iterR)>::decoder<TYPEOF_GET_NEXT(iterR)> 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<FUN_PTR_ID + n>
|
||||
{
|
||||
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
|
||||
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<V>::type,
|
||||
R,
|
||||
types_0
|
||||
>::encoded_type
|
||||
)
|
||||
);
|
||||
friend sizer<FUN_PTR_ID + n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
template<typename V,typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
|
||||
typename encode_impl<FUN_PTR_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<>
|
||||
struct decode_impl<FUN_PTR_ID + n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef Iter iterR;
|
||||
typedef decode_impl<TYPEOF_GET_VALUE(iterR)>::decoder<TYPEOF_GET_NEXT(iterR)> 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 <boost/typeof/vintage/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier const
|
||||
#define BOOST_TYPEOF_id CONST_MEM_FUN_ID
|
||||
|
||||
#include <boost/typeof/vintage/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier volatile
|
||||
#define BOOST_TYPEOF_id VOLATILE_MEM_FUN_ID
|
||||
|
||||
#include <boost/typeof/vintage/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier volatile const
|
||||
#define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
|
||||
|
||||
#include <boost/typeof/vintage/register_mem_functions.hpp>
|
||||
|
||||
#undef n
|
59
include/boost/typeof/vintage/register_mem_functions.hpp
Normal file
59
include/boost/typeof/vintage/register_mem_functions.hpp
Normal file
@ -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<BOOST_TYPEOF_id + n>
|
||||
{
|
||||
template<typename V,typename R,typename T BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A),typename Types>
|
||||
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<V>::type,
|
||||
R,
|
||||
type_list<T,types_0>
|
||||
>::encoded_type
|
||||
)
|
||||
);
|
||||
friend sizer<BOOST_TYPEOF_id + n> encode_value(const sizer<V::index>&,const sizer<V::pos>&);
|
||||
};
|
||||
};
|
||||
|
||||
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<>
|
||||
struct decode_impl<BOOST_TYPEOF_id + n>
|
||||
{
|
||||
template<typename Iter>
|
||||
struct decoder {
|
||||
typedef Iter iterR;
|
||||
typedef decode_impl<TYPEOF_GET_VALUE(iterR)>::decoder<TYPEOF_GET_NEXT(iterR)> decodeR;\
|
||||
typedef typename decodeR::type R;
|
||||
typedef typename decodeR::iter iterT;
|
||||
typedef decode_impl<TYPEOF_GET_VALUE(iterT)>::decoder<TYPEOF_GET_NEXT(iterT)> decodeT;\
|
||||
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_)>
|
||||
struct workaround {
|
||||
typedef R_ (T_::*type)(BOOST_PP_ENUM_PARAMS(n,A_)) 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 BOOST_PP_CAT(iter,n) iter;
|
||||
};
|
||||
};
|
||||
|
||||
#undef BOOST_TYPEOF_id
|
||||
#undef BOOST_TYPEOF_qualifier
|
101
include/boost/typeof/vintage/sizer.hpp
Normal file
101
include/boost/typeof/vintage/sizer.hpp
Normal file
@ -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 <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#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<unsigned S>
|
||||
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<int N> struct encode_counter : encode_counter<N - 1> {};
|
||||
template<> struct encode_counter<0> {};
|
||||
|
||||
#ifdef BOOST_MAX_RECURSION
|
||||
#define BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER(z,n,text)\
|
||||
template<> struct encode_counter<BOOST_MAX_RECURSION*BOOST_PP_INC(n)> {};
|
||||
|
||||
BOOST_PP_REPEAT(20,BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER,_)
|
||||
#undef BOOST_TYPEOF_SPECIALIZE_ENCODE_COUNTER
|
||||
|
||||
|
||||
template<typename T,int N=BOOST_MAX_RECURSION>
|
||||
struct counter_start
|
||||
{
|
||||
template<bool>
|
||||
struct increase_limit {
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=(counter_start<T,N+BOOST_MAX_RECURSION>::value));
|
||||
};
|
||||
template<>
|
||||
struct increase_limit<false>
|
||||
{
|
||||
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<current>*)NULL))==current));
|
||||
BOOST_STATIC_CONSTANT(bool,start_next=(sizeof(encode_index((encode_counter<next>*)NULL))>1));
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=(increase_limit<exceed_current&&start_next>::value));
|
||||
typedef encode_counter<value> type;
|
||||
};
|
||||
|
||||
#define BOOST_TYPEOF_INDEX(T) (sizeof(boost::type_of::encode_index((boost::type_of::counter_start<T>::type*)0)))
|
||||
#else
|
||||
|
||||
#define BOOST_TYPEOF_INDEX(T) (sizeof(boost::type_of::encode_index((boost::type_of::encode_counter<BOOST_MAX_TYPEOF_COUNTER+BOOST_MIN_TYPEOF_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<BOOST_MIN_TYPEOF_COUNTER> encode_index(...);
|
||||
/*
|
||||
#define BOOST_TYPEOF_VALUE(N) (sizeof(boost::type_of::encode_value((boost::type_of::encode_counter<N>*)0)))
|
||||
#define BOOST_TYPEOF_INDEX() (sizeof(*boost::type_of::encode_index((boost::type_of::encode_counter<BOOST_MAX_TYPEOF_COUNTER+BOOST_MIN_TYPEOF_COUNTER>*)0)))
|
||||
*/
|
||||
|
||||
}}//namespace boost::type_of
|
||||
|
||||
#endif //BOOST_TYPEOF_SIZER_HPP_HOLT_2004_0819
|
||||
|
89
include/boost/typeof/vintage/template_encoding.hpp
Normal file
89
include/boost/typeof/vintage/template_encoding.hpp
Normal file
@ -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 <boost/preprocessor/punctuation/paren.hpp>
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
#include <boost/preprocessor/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#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>
|
||||
|
||||
//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()
|
||||
|
||||
//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_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_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_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_TYPEOF_ENCODE_SEQ_ELEMENT(z,n,seq),
|
||||
#define BOOST_TYPEOF_STORE_TYPE_END(z,n,seq) > BOOST_PP_EMPTY()
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_TEMPLATE(template_type,seq)\
|
||||
template<>\
|
||||
struct encode_impl<BOOST_TYPEOF_UNIQUE_ID()>\
|
||||
{\
|
||||
template<typename V, BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(seq),typename A),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))\
|
||||
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>&);\
|
||||
};\
|
||||
};\
|
||||
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));
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_TEMPLATE(template_type,seq)\
|
||||
template<>\
|
||||
struct decode_impl<BOOST_TYPEOF_UNIQUE_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;\
|
||||
};\
|
||||
};
|
||||
|
||||
#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
|
48
include/boost/typeof/vintage/type_encoding.hpp
Normal file
48
include/boost/typeof/vintage/type_encoding.hpp
Normal file
@ -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 <boost/typeof/config.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_TYPE(simple_type)\
|
||||
template<>\
|
||||
struct encode_impl<BOOST_TYPEOF_UNIQUE_ID()>\
|
||||
{\
|
||||
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<BOOST_TYPEOF_UNIQUE_ID()> encode_value(const sizer<V::index>&,const sizer<V::pos>&);\
|
||||
};\
|
||||
};\
|
||||
template<typename V,typename Types>\
|
||||
typename encode_impl<BOOST_TYPEOF_UNIQUE_ID()>::encoder<V,Types> encode(simple_type const& (*)(V,Types));
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_TYPE(simple_type)\
|
||||
template<>\
|
||||
struct decode_impl<BOOST_TYPEOF_UNIQUE_ID()>\
|
||||
{\
|
||||
template<typename Iter>\
|
||||
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
|
26
include/boost/typeof/vintage/type_list.hpp
Normal file
26
include/boost/typeof/vintage/type_list.hpp
Normal file
@ -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<typename T,typename Next=empty_type_list>
|
||||
struct type_list {
|
||||
typedef T type;
|
||||
typedef Next next;
|
||||
};
|
||||
|
||||
template<typename V,typename Types>
|
||||
int
|
||||
encode(empty_type_list const& (*)(V,Types));
|
||||
|
||||
}}//namespace boost::type_of
|
||||
|
||||
#endif //BOOST_TYPEOF_VINTAGE_TYPE_LIST_HPP_INCLUDED
|
||||
|
68
include/boost/typeof/vintage/type_to_macro.hpp
Normal file
68
include/boost/typeof/vintage/type_to_macro.hpp
Normal file
@ -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 <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/punctuation/paren.hpp>
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
|
||||
/*
|
||||
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<MyEnum value>
|
||||
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
|
||||
|
61
include/boost/typeof/vintage/typeof_impl.hpp
Normal file
61
include/boost/typeof/vintage/typeof_impl.hpp
Normal file
@ -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 <boost/typeof/vintage/encode_decode.hpp>
|
||||
#include <boost/typeof/vintage/sizer.hpp>
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
template<unsigned Index,unsigned Position=1>
|
||||
struct iterator {
|
||||
BOOST_STATIC_CONSTANT(unsigned,index=Index);
|
||||
BOOST_STATIC_CONSTANT(unsigned,pos=Position);
|
||||
typedef iterator<Index,pos+1> next;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct encode_type
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T));
|
||||
BOOST_STATIC_CONSTANT(unsigned,encode_dummy=sizeof(BOOST_DEDUCED_TYPENAME encode_modifier<iterator<value>,T,empty_type_list>::encoded_type));
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned,next=value+1);
|
||||
friend sizer<next> encode_index(encode_counter<next>*);
|
||||
|
||||
sizer<value> resize;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
encode_type<T> encode_start(T const&);
|
||||
|
||||
template<typename Iter>
|
||||
struct decode {
|
||||
typedef typename decode_impl<Iter::value>::decoder<Iter::next>::type type;
|
||||
};
|
||||
template<>
|
||||
struct decode<int> {
|
||||
typedef int type;
|
||||
};
|
||||
template<unsigned Index,unsigned Position=1>
|
||||
struct value_iterator {
|
||||
BOOST_STATIC_CONSTANT(unsigned,pos=Position);
|
||||
BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_VALUE(sizer<Index>,sizer<pos>));
|
||||
typedef value_iterator<Index,pos+1> next;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_TYPEOF(expr) \
|
||||
boost::type_of::decode<boost::type_of::value_iterator<sizeof(boost::type_of::encode_start(expr))> >::type
|
||||
|
||||
#define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr)
|
||||
|
||||
|
||||
#endif//BOOST_TYPEOF_VINTAGE_TYPEOF_IMPL_HPP_INCLUDED
|
||||
|
||||
|
Reference in New Issue
Block a user