forked from boostorg/typeof
initial commit
[SVN r2349]
This commit is contained in:
67
include/boost/typeof/compliant/concatenate.hpp
Executable file
67
include/boost/typeof/compliant/concatenate.hpp
Executable file
@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_CONCATENATE_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_CONCATENATE_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
|
||||
// Assumes iter0 contains initial iterator
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_PARAM(z, n, text) \
|
||||
typedef decode_type<iter##n> decode##n; \
|
||||
typedef typename decode##n::type p##n; \
|
||||
typedef typename decode##n::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_DECODE_PARAMS(n)\
|
||||
BOOST_PP_REPEAT(n, BOOST_TYPEOF_DECODE_PARAM, BOOST_PP_EMPTY());
|
||||
|
||||
// The P0, P1, ... PN are encoded and added to V
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_PARAMS_BEGIN(z, n, text)\
|
||||
typename encode_type<
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_PARAMS_END(z, n, text)\
|
||||
, BOOST_PP_CAT(P, n)>::type
|
||||
|
||||
#define BOOST_TYPEOF_ENCODE_PARAMS(n, ID) \
|
||||
BOOST_PP_REPEAT(n, BOOST_TYPEOF_ENCODE_PARAMS_BEGIN, BOOST_PP_EMPTY()) \
|
||||
typename BOOST_TYPEOF_PUSH_BACK<V, mpl::size_t<ID> >::type \
|
||||
BOOST_PP_REPEAT(n, BOOST_TYPEOF_ENCODE_PARAMS_END, BOOST_PP_EMPTY())
|
||||
|
||||
// constant-time push_back for mpl::vector
|
||||
// to be removed once real one is available from MPL
|
||||
|
||||
#define BOOST_TYPEOF_spec_push_back(z, i, text) \
|
||||
template<class T BOOST_PP_ENUM_TRAILING_PARAMS(i, class T)> \
|
||||
struct push_back<BOOST_PP_CAT(mpl::vector, i)<BOOST_PP_ENUM_PARAMS(i, T)>, T> \
|
||||
{ \
|
||||
typedef BOOST_PP_CAT(mpl::vector, BOOST_PP_INC(i))< \
|
||||
BOOST_PP_ENUM_PARAMS(i, T) BOOST_PP_COMMA_IF(i) T \
|
||||
> type; \
|
||||
}; \
|
||||
|
||||
#define BOOST_TYPEOF_implement_push_back() \
|
||||
template<class V, class T> struct push_back; \
|
||||
BOOST_PP_REPEAT( \
|
||||
BOOST_TYPEOF_LIMIT_SIZE, \
|
||||
BOOST_TYPEOF_spec_push_back, \
|
||||
~ \
|
||||
) \
|
||||
|
||||
namespace boost{namespace type_of{namespace detail{
|
||||
BOOST_TYPEOF_implement_push_back();
|
||||
}}}
|
||||
|
||||
#undef BOOST_TYPEOF_spec_push_back
|
||||
#undef BOOST_TYPEOF_implement_push_back
|
||||
|
||||
#endif//BOOST_TYPEOF_CONCATENATE_HPP_INCLUDED
|
28
include/boost/typeof/compliant/encode_decode.hpp
Executable file
28
include/boost/typeof/compliant/encode_decode.hpp
Executable file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_ENCODE_DECODE_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_ENCODE_DECODE_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
namespace
|
||||
{
|
||||
template<class V, class T> struct encode_type_impl;
|
||||
template<class T, class Iter> struct decode_type_impl;
|
||||
}
|
||||
|
||||
template<class V, class T> struct encode_type
|
||||
: encode_type_impl<V, T>
|
||||
{};
|
||||
|
||||
template<class Iter> struct decode_type
|
||||
: decode_type_impl<typename mpl::deref<Iter>::type, typename mpl::next<Iter>::type>
|
||||
{};
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_ENCODE_DECODE_HPP_INCLUDED
|
89
include/boost/typeof/compliant/int_encoding.hpp
Executable file
89
include/boost/typeof/compliant/int_encoding.hpp
Executable file
@ -0,0 +1,89 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_INT_ENCODING_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_INT_ENCODING_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
template<class T, T n>
|
||||
struct split
|
||||
{
|
||||
static const size_t u = (size_t)n;
|
||||
static const size_t value1 = (u >> 16) + 1;
|
||||
static const size_t value2 = (u << 16 >> 16) + 1;
|
||||
};
|
||||
|
||||
template<class T, size_t u1, size_t u2>
|
||||
struct join
|
||||
{
|
||||
static const T value = (T)(((u1 - 1) << 16) + (u2 - 1));
|
||||
};
|
||||
|
||||
template<class V, class T, T n>
|
||||
struct encode_long_integral
|
||||
{
|
||||
typedef
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<split<T, n>::value1> >::type
|
||||
, mpl::size_t<split<T, n>::value2> >::type
|
||||
type;
|
||||
};
|
||||
|
||||
template<class T, class Iter>
|
||||
struct decode_long_integral
|
||||
{
|
||||
static const T value = join<
|
||||
T,
|
||||
mpl::deref<Iter>::type::value,
|
||||
mpl::deref<typename mpl::next<Iter>::type>::type::value
|
||||
>::value;
|
||||
|
||||
typedef typename mpl::next<typename mpl::next<Iter>::type>::type iter;
|
||||
};
|
||||
|
||||
template<class V, class T, T n>
|
||||
struct encode_short_integral
|
||||
{
|
||||
typedef
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<(size_t)n + 1> >::type
|
||||
type;
|
||||
};
|
||||
|
||||
template<class T, class Iter>
|
||||
struct decode_short_integral
|
||||
{
|
||||
static const T value = (T)(mpl::deref<Iter>::type::value - 1);
|
||||
typedef typename mpl::next<Iter>::type iter;
|
||||
};
|
||||
|
||||
template<class V, class T, T n>
|
||||
struct encode_integral : mpl::if_c<
|
||||
(sizeof(T) < 4),
|
||||
encode_short_integral<V, T, n>,
|
||||
encode_long_integral<V, T, n>
|
||||
>::type
|
||||
{};
|
||||
|
||||
template<class T, class Iter>
|
||||
struct decode_integral : mpl::if_c<
|
||||
(sizeof(T) < 4),
|
||||
decode_short_integral<T, Iter>,
|
||||
decode_long_integral<T, Iter>
|
||||
>::type
|
||||
{};
|
||||
}
|
||||
}//namespace
|
||||
|
||||
#endif//BOOST_TYPEOF_INT_ENCODING_HPP_INCLUDED
|
35
include/boost/typeof/compliant/limit_size.hpp
Executable file
35
include/boost/typeof/compliant/limit_size.hpp
Executable file
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_LIMIT_SIZE_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_LIMIT_SIZE_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/vector.hpp"
|
||||
#include "boost/mpl/aux_/config/ctps.hpp"
|
||||
#include "boost/preprocessor/iterate.hpp"
|
||||
#include "boost/preprocessor/if.hpp"
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#ifndef BOOST_TYPEOF_LIMIT_SIZE
|
||||
#define BOOST_TYPEOF_LIMIT_SIZE 50
|
||||
#endif//BOOST_TYPEOF_LIMIT_SIZE
|
||||
|
||||
#if (BOOST_TYPEOF_LIMIT_SIZE > BOOST_MPL_LIMIT_VECTOR_SIZE)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace mpl
|
||||
{
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 (3,( \
|
||||
BOOST_PP_INC(BOOST_MPL_LIMIT_VECTOR_SIZE), \
|
||||
BOOST_TYPEOF_LIMIT_SIZE, \
|
||||
"boost/mpl/vector/aux_/numbered.hpp"))
|
||||
|
||||
#include BOOST_PP_ITERATE()
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_LIMIT_SIZE > BOOST_MPL_LIMIT_VECTOR_SIZE
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_LIMIT_SIZE_HPP_INCLUDED
|
54
include/boost/typeof/compliant/lvalue_typeof.hpp
Executable file
54
include/boost/typeof/compliant/lvalue_typeof.hpp
Executable file
@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_LVALUE_TYPEOF_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_LVALUE_TYPEOF_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<class T, int n> struct decorate_type
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template<class T> struct decorate_type<T, LVALUE>
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
template<class T> struct decorate_type<T, CONST_LVALUE>
|
||||
{
|
||||
typedef const T& type;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Since this is always a type,
|
||||
// just add "typename" when using in templates
|
||||
|
||||
#define BOOST_LVALUE_TYPEOF(expr) \
|
||||
boost::type_of::decorate_type< \
|
||||
BOOST_TYPEOF(expr), \
|
||||
sizeof(boost::type_of::classify_expression(expr)) \
|
||||
>::type
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_LVALUE_TYPEOF_HPP_INCLUDED
|
118
include/boost/typeof/compliant/modifiers.hpp
Executable file
118
include/boost/typeof/compliant/modifiers.hpp
Executable file
@ -0,0 +1,118 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_MODIFIERS_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_MODIFIERS_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/compliant/encode_decode.hpp>
|
||||
#include <boost/typeof/compliant/concatenate.hpp>
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
namespace
|
||||
{
|
||||
enum
|
||||
{
|
||||
CONST_ID = BOOST_TYPEOF_UNIQUE_ID(),
|
||||
PTR_ID,
|
||||
REF_ID,
|
||||
ARRAY_ID,
|
||||
CONST_ARRAY_ID
|
||||
};
|
||||
|
||||
template<class V, class T> struct encode_type_impl<V, const T>
|
||||
{
|
||||
typedef
|
||||
typename encode_type<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<CONST_ID> >::type
|
||||
, T>::type
|
||||
type;
|
||||
};
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<CONST_ID>, Iter>
|
||||
{
|
||||
typedef decode_type<Iter> d1;
|
||||
typedef const typename d1::type type;
|
||||
typedef typename d1::iter iter;
|
||||
};
|
||||
template<class V, class T> struct encode_type_impl<V, T*>
|
||||
{
|
||||
typedef
|
||||
typename encode_type<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<PTR_ID> >::type
|
||||
, T>::type
|
||||
type;
|
||||
};
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<PTR_ID>, Iter>
|
||||
{
|
||||
typedef decode_type<Iter> d1;
|
||||
typedef typename d1::type* type;
|
||||
typedef typename d1::iter iter;
|
||||
};
|
||||
template<class V, class T> struct encode_type_impl<V, T&>
|
||||
{
|
||||
typedef
|
||||
typename encode_type<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<REF_ID> >::type
|
||||
, T>::type
|
||||
type;
|
||||
};
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<REF_ID>, Iter>
|
||||
{
|
||||
typedef decode_type<Iter> d1;
|
||||
typedef typename d1::type& type;
|
||||
typedef typename d1::iter iter;
|
||||
};
|
||||
template<class V, class T, int N> struct encode_type_impl<V, T[N]>
|
||||
{
|
||||
typedef
|
||||
typename encode_type<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<ARRAY_ID> >::type
|
||||
, mpl::size_t<N> >::type
|
||||
, T>::type
|
||||
type;
|
||||
};
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<ARRAY_ID>, Iter>
|
||||
{
|
||||
enum{n = mpl::deref<Iter>::type::value};
|
||||
typedef decode_type<typename mpl::next<Iter>::type> d;
|
||||
typedef typename d::type type[n];
|
||||
typedef typename d::iter iter;
|
||||
};
|
||||
template<class V, class T, int N> struct encode_type_impl<V, const T[N]>
|
||||
{
|
||||
typedef
|
||||
typename encode_type<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
typename BOOST_TYPEOF_PUSH_BACK<
|
||||
V
|
||||
, mpl::size_t<CONST_ARRAY_ID> >::type
|
||||
, mpl::size_t<N> >::type
|
||||
, T>::type
|
||||
type;
|
||||
};
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<CONST_ARRAY_ID>, Iter>
|
||||
{
|
||||
enum{n = mpl::deref<Iter>::type::value};
|
||||
typedef decode_type<typename mpl::next<Iter>::type> d;
|
||||
typedef typename d::type const type[n];
|
||||
typedef typename d::iter iter;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_MODIFIERS_HPP_INCLUDED
|
44
include/boost/typeof/compliant/pointers_data_members.hpp
Executable file
44
include/boost/typeof/compliant/pointers_data_members.hpp
Executable file
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_POINTERS_DATA_MEMBERS_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_POINTERS_DATA_MEMBERS_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/compliant/concatenate.hpp>
|
||||
#include <boost/typeof/compliant/encode_decode.hpp>
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
namespace
|
||||
{
|
||||
enum {PTR_DATA_MEM_ID = BOOST_TYPEOF_UNIQUE_ID()};
|
||||
|
||||
template<class V, class P0, class P1>
|
||||
struct encode_type_impl<V, P0 P1::*>
|
||||
{
|
||||
typedef BOOST_TYPEOF_ENCODE_PARAMS(2, PTR_DATA_MEM_ID) type;
|
||||
};
|
||||
|
||||
template<class Iter>
|
||||
struct decode_type_impl<mpl::size_t<PTR_DATA_MEM_ID>, Iter>
|
||||
{
|
||||
typedef Iter iter0;
|
||||
BOOST_TYPEOF_DECODE_PARAMS(2)
|
||||
|
||||
template<class T> struct workaround{
|
||||
typedef p0 T::* type;
|
||||
};
|
||||
|
||||
typedef typename workaround<p1>::type type;
|
||||
typedef iter2 iter;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_POINTERS_DATA_MEMBERS_HPP_INCLUDED
|
43
include/boost/typeof/compliant/register_functions_iterate.hpp
Executable file
43
include/boost/typeof/compliant/register_functions_iterate.hpp
Executable file
@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define n BOOST_PP_ITERATION()
|
||||
|
||||
// functions
|
||||
|
||||
template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
|
||||
struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P))>
|
||||
{
|
||||
typedef R BOOST_PP_CAT(P, n);
|
||||
typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_ID + n) type;
|
||||
};
|
||||
|
||||
template<class Iter>
|
||||
struct decode_type_impl<mpl::size_t<FUN_ID + n>, Iter>
|
||||
{
|
||||
typedef Iter iter0;
|
||||
BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
|
||||
typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p));
|
||||
typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
|
||||
};
|
||||
|
||||
// member functions
|
||||
|
||||
#define BOOST_TYPEOF_qualifier
|
||||
#define BOOST_TYPEOF_id MEM_FUN_ID
|
||||
#include <boost/typeof/compliant/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier const
|
||||
#define BOOST_TYPEOF_id CONST_MEM_FUN_ID
|
||||
#include <boost/typeof/compliant/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier volatile
|
||||
#define BOOST_TYPEOF_id VOLATILE_MEM_FUN_ID
|
||||
#include <boost/typeof/compliant/register_mem_functions.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_qualifier volatile const
|
||||
#define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
|
||||
#include <boost/typeof/compliant/register_mem_functions.hpp>
|
||||
|
||||
#undef n
|
30
include/boost/typeof/compliant/register_mem_functions.hpp
Executable file
30
include/boost/typeof/compliant/register_mem_functions.hpp
Executable file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// member functions
|
||||
|
||||
template<class V, class T, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
|
||||
struct encode_type_impl<V, R(T::*)(BOOST_PP_ENUM_PARAMS(n, P)) BOOST_TYPEOF_qualifier>
|
||||
{
|
||||
typedef R BOOST_PP_CAT(P, n);
|
||||
typedef T BOOST_PP_CAT(P, BOOST_PP_INC(n));
|
||||
typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_ADD(n, 2), BOOST_TYPEOF_id + n) type;
|
||||
};
|
||||
|
||||
template<class Iter>
|
||||
struct decode_type_impl<mpl::size_t<BOOST_TYPEOF_id + n>, Iter>
|
||||
{
|
||||
typedef Iter iter0;
|
||||
BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_ADD(n, 2))
|
||||
template<class T> struct workaround{
|
||||
typedef BOOST_PP_CAT(p, n)(T::*type)(BOOST_PP_ENUM_PARAMS(n, p)) BOOST_TYPEOF_qualifier;
|
||||
};
|
||||
typedef typename workaround<BOOST_PP_CAT(p, BOOST_PP_INC(n))>::type type;
|
||||
typedef BOOST_PP_CAT(iter, BOOST_PP_ADD(n, 2)) iter;
|
||||
};
|
||||
|
||||
// undef parameters
|
||||
|
||||
#undef BOOST_TYPEOF_id
|
||||
#undef BOOST_TYPEOF_qualifier
|
182
include/boost/typeof/compliant/template_encoding.hpp
Executable file
182
include/boost/typeof/compliant/template_encoding.hpp
Executable file
@ -0,0 +1,182 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/compliant/encode_decode.hpp>
|
||||
#include <boost/typeof/compliant/int_encoding.hpp>
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing.hpp>
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_class_ BOOST_TYPEOF_REGISTER_TEMPLATE_typename_
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_typename_ (typename) (void) (TYPE)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_integral(x) (x) (x) (VALUE)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_RESULT_TYPE(x) typename x::type
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_RESULT_VALUE(x) x::value
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_char_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_short_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_int_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_long_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(long)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_bool_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(bool)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsigned_ BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedchar BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned char)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedshort BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned short)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedint BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned int)
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_unsignedlong BOOST_TYPEOF_REGISTER_TEMPLATE_integral(unsigned long)
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_TO_SEQ(tokens) BOOST_TYPEOF_ ## tokens ## _BOOST_TYPEOF
|
||||
|
||||
#define BOOST_TYPEOF_unsigned (unsigned)
|
||||
|
||||
#define BOOST_TYPEOF_char_BOOST_TYPEOF (char)(_)
|
||||
#define BOOST_TYPEOF_short_BOOST_TYPEOF (short)(_)
|
||||
#define BOOST_TYPEOF_int_BOOST_TYPEOF (int)(_)
|
||||
#define BOOST_TYPEOF_long_BOOST_TYPEOF (long)(_)
|
||||
#define BOOST_TYPEOF_bool_BOOST_TYPEOF (bool)(_)
|
||||
#define BOOST_TYPEOF_class_BOOST_TYPEOF (class)(_)
|
||||
#define BOOST_TYPEOF_typename_BOOST_TYPEOF (typename)(_)
|
||||
#define BOOST_TYPEOF_unsigned_BOOST_TYPEOF (unsigned)(_)
|
||||
|
||||
#define char_BOOST_TYPEOF (char)
|
||||
#define short_BOOST_TYPEOF (short)
|
||||
#define int_BOOST_TYPEOF (int)
|
||||
#define long_BOOST_TYPEOF (long)
|
||||
|
||||
#define EAT_SPACE(tokens) BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_TO_SEQ(tokens)), BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_TO_SEQ(tokens)))
|
||||
|
||||
///////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params)\
|
||||
BOOST_PP_CAT(BOOST_TYPEOF_REGISTER_TEMPLATE_, EAT_SPACE(BOOST_PP_SEQ_ELEM(n, Params)))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(0, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SPEC_TYPE(n, Params)\
|
||||
BOOST_PP_SEQ_ELEM(1, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_RESULT(n, Params)\
|
||||
BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_RESULT_,\
|
||||
BOOST_PP_SEQ_ELEM(2, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_DESCR(n, Params))\
|
||||
)
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(z, n, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_TYPE(n, Params) BOOST_PP_CAT(P, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(z, n, Params)\
|
||||
typedef typename encode_dispatcher<\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SPEC_TYPE(n, Params)\
|
||||
>::encode<BOOST_PP_CAT(V, n), BOOST_PP_CAT(P, n)>::type BOOST_PP_CAT(V, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(z, n, Params)\
|
||||
typedef encode_dispatcher<\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_SPEC_TYPE(n, Params)\
|
||||
>::decode<BOOST_PP_CAT(iter, n)> BOOST_PP_CAT(d, BOOST_PP_INC(n));\
|
||||
typedef typename BOOST_PP_CAT(d, BOOST_PP_INC(n))::iter BOOST_PP_CAT(iter, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM_RESULT(z, n, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_RESULT(n, Params)(BOOST_PP_CAT(d, BOOST_PP_INC(n)))
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_X_IMPL(Name, Params, ID)\
|
||||
namespace boost{namespace type_of{namespace{\
|
||||
template<class V\
|
||||
BOOST_PP_ENUM_TRAILING(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR,\
|
||||
Params)\
|
||||
>\
|
||||
struct encode_type_impl<V, Name<\
|
||||
BOOST_PP_ENUM_PARAMS(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
P)> >\
|
||||
{\
|
||||
typedef typename BOOST_TYPEOF_PUSH_BACK<V, mpl::size_t<ID> >::type V0;\
|
||||
BOOST_PP_REPEAT(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM,\
|
||||
Params)\
|
||||
typedef BOOST_PP_CAT(V, BOOST_PP_SEQ_SIZE(Params)) type;\
|
||||
};\
|
||||
template<class Iter>\
|
||||
struct decode_type_impl<boost::mpl::size_t<ID>, Iter>\
|
||||
{\
|
||||
typedef Iter iter0;\
|
||||
BOOST_PP_REPEAT(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM,\
|
||||
Params)\
|
||||
typedef Name<\
|
||||
BOOST_PP_ENUM(\
|
||||
BOOST_PP_SEQ_SIZE(Params),\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM_RESULT,\
|
||||
Params)\
|
||||
> type;\
|
||||
typedef BOOST_PP_CAT(iter, BOOST_PP_SEQ_SIZE(Params)) iter;\
|
||||
};\
|
||||
}}}
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_X(Name, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X_IMPL(Name, Params, BOOST_TYPEOF_UNIQUE_ID())
|
||||
|
||||
//////////
|
||||
|
||||
#define BOOST_TYPEOF_spec_integral_dispatcher(r, data, T) \
|
||||
template<> struct encode_dispatcher<T> \
|
||||
{ \
|
||||
template<class V, T n> \
|
||||
struct encode : encode_integral<V, T, n> \
|
||||
{}; \
|
||||
template<class Iter> \
|
||||
struct decode : decode_integral<T, Iter> \
|
||||
{}; \
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
template<class U = void> struct encode_dispatcher
|
||||
{
|
||||
template<class V, class T>
|
||||
struct encode : encode_type<V, T>
|
||||
{};
|
||||
template<class Iter>
|
||||
struct decode : decode_type<Iter>
|
||||
{};
|
||||
};
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(BOOST_TYPEOF_spec_integral_dispatcher, ~,
|
||||
(char)
|
||||
(short)
|
||||
(int)
|
||||
(long)
|
||||
(bool)
|
||||
(unsigned char)
|
||||
(unsigned short)
|
||||
(unsigned int)
|
||||
(unsigned long)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#undef BOOST_TYPEOF_spec_integral_dispatcher
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_TEMPLATE_ENCODING_HPP_INCLUDED
|
26
include/boost/typeof/compliant/type_encoding.hpp
Executable file
26
include/boost/typeof/compliant/type_encoding.hpp
Executable file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_TYPE_ENCODING_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_TYPE_ENCODING_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/compliant/concatenate.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TYPE_IMPL(T, Id) \
|
||||
\
|
||||
template<class V> struct encode_type_impl<V, T > \
|
||||
: BOOST_TYPEOF_PUSH_BACK<V, mpl::size_t<Id> > \
|
||||
{}; \
|
||||
template<class Iter> struct decode_type_impl<mpl::size_t<Id>, Iter> \
|
||||
{ \
|
||||
typedef T type; \
|
||||
typedef Iter iter; \
|
||||
};
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TYPE(Type) \
|
||||
namespace boost{namespace type_of{namespace{ \
|
||||
BOOST_TYPEOF_REGISTER_TYPE_IMPL(Type, BOOST_TYPEOF_UNIQUE_ID()) \
|
||||
}}}
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_TYPE_ENCODING_HPP_INCLUDED
|
62
include/boost/typeof/compliant/typeof_impl.hpp
Executable file
62
include/boost/typeof/compliant/typeof_impl.hpp
Executable file
@ -0,0 +1,62 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_COMPLIANT_TYPEOF_IMPL_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_COMPLIANT_TYPEOF_IMPL_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
|
||||
#define BOOST_TYPEOF_PUSH_BACK detail::push_back
|
||||
//#define BOOST_TYPEOF_PUSH_BACK mpl::push_back
|
||||
|
||||
#include <boost/typeof/compliant/limit_size.hpp>
|
||||
#include <boost/typeof/compliant/encode_decode.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
template<int pos, class T>
|
||||
char(&at(const T&))[
|
||||
mpl::at<typename encode_type<mpl::vector0<>, T>::type, mpl::size_t<pos> >::type::value
|
||||
];
|
||||
|
||||
template<class T>
|
||||
char(&size(const T&))[
|
||||
mpl::size<typename encode_type<mpl::vector0<>, T>::type>::value
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_TYPEOF_AT(n, expr) sizeof(boost::type_of::at<n>(expr))
|
||||
#define BOOST_TYPEOF_SIZE(expr) sizeof(boost::type_of::size(expr))
|
||||
|
||||
#define BOOST_TYPEOF_TYPEITEM(z, n, expr)\
|
||||
boost::mpl::size_t<BOOST_TYPEOF_AT((n < BOOST_TYPEOF_SIZE(expr)) ? n : 0, expr)>
|
||||
|
||||
#define BOOST_TYPEOF(Expr) \
|
||||
boost::type_of::decode_type< \
|
||||
boost::mpl::begin< \
|
||||
BOOST_PP_CAT(boost::mpl::vector, BOOST_TYPEOF_LIMIT_SIZE)< \
|
||||
BOOST_PP_ENUM(BOOST_TYPEOF_LIMIT_SIZE, BOOST_TYPEOF_TYPEITEM, Expr) \
|
||||
> \
|
||||
>::type \
|
||||
>::type
|
||||
|
||||
#define BOOST_TYPEOF_TPL(Expr) \
|
||||
typename boost::type_of::decode_type< \
|
||||
typename boost::mpl::begin< \
|
||||
BOOST_PP_CAT(boost::mpl::vector, BOOST_TYPEOF_LIMIT_SIZE)< \
|
||||
BOOST_PP_ENUM(BOOST_TYPEOF_LIMIT_SIZE, BOOST_TYPEOF_TYPEITEM, Expr) \
|
||||
> \
|
||||
>::type \
|
||||
>::type
|
||||
|
||||
#endif//BOOST_TYPEOF_COMPLIANT_TYPEOF_IMPL_HPP_INCLUDED
|
26
include/boost/typeof/config.hpp
Executable file
26
include/boost/typeof/config.hpp
Executable file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_CONFIG_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_CONFIG_HPP_INCLUDED
|
||||
|
||||
#if !defined(BOOST_TYPEOF_COMPLIANT) && !defined(BOOST_TYPEOF_VINTAGE) && !defined(BOOST_TYPEOF_NATIVE)
|
||||
|
||||
# if defined __GNUC__
|
||||
# define BOOST_TYPEOF_NATIVE
|
||||
|
||||
# elif defined __MWERKS__
|
||||
# define BOOST_TYPEOF_NATIVE
|
||||
|
||||
# elif defined BOOST_TYPEOF_NO_PARTIAL_TEMPLATE_SPECIALIZATION
|
||||
# define BOOST_TYPEOF_VINTAGE
|
||||
|
||||
# else
|
||||
# define BOOST_TYPEOF_COMPLIANT
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif//BOOST_TYPEOF_CONFIG_HPP_INCLUDED
|
21
include/boost/typeof/increment_registration_group.hpp
Executable file
21
include/boost/typeof/increment_registration_group.hpp
Executable file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Inclusion of this file increments BOOST_TYPEOF_REGISTRATION_GROUP
|
||||
// This method was suggested by Paul Mensonides
|
||||
|
||||
#ifndef BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP_HPP_INCLUDED
|
||||
|
||||
# define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP_HPP_INCLUDED
|
||||
# include <boost/preprocessor/slot/slot.hpp>
|
||||
# define BOOST_TYPEOF_REGISTRATION_GROUP 0
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_PP_VALUE BOOST_TYPEOF_REGISTRATION_GROUP + 1
|
||||
# include BOOST_PP_ASSIGN_SLOT(1)
|
||||
# undef BOOST_TYPEOF_REGISTRATION_GROUP
|
||||
# define BOOST_TYPEOF_REGISTRATION_GROUP BOOST_PP_SLOT(1)
|
||||
|
||||
#endif//BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP_HPP_INCLUDED
|
51
include/boost/typeof/register_functions.hpp
Executable file
51
include/boost/typeof/register_functions.hpp
Executable file
@ -0,0 +1,51 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_REGISTER_FUNCTIONS_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_REGISTER_FUNCTIONS_HPP_INCLUDED
|
||||
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/inc.hpp>
|
||||
#include <boost/preprocessor/dec.hpp>
|
||||
#include <boost/preprocessor/if.hpp>
|
||||
#include <boost/preprocessor/arithmetic/add.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
#ifndef BOOST_TYPEOF_FUN_PARAMS_SUPPORTED
|
||||
#define BOOST_TYPEOF_FUN_PARAMS_SUPPORTED 10
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FUN_ID = BOOST_TYPEOF_UNIQUE_ID(),
|
||||
VOID_FUN_ID = FUN_ID + 1 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
MEM_FUN_ID = FUN_ID + 2 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
CONST_MEM_FUN_ID = FUN_ID + 3 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
VOID_MEM_FUN_ID = FUN_ID + 4 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
CONST_VOID_MEM_FUN_ID = FUN_ID + 5 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
VOLATILE_MEM_FUN_ID = FUN_ID + 6 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
VOLATILE_CONST_MEM_FUN_ID = FUN_ID + 7 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
VOLATILE_VOID_MEM_FUN_ID = FUN_ID + 8 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED),
|
||||
VOLATILE_CONST_VOID_MEM_FUN_ID = FUN_ID + 9 * BOOST_PP_INC(BOOST_TYPEOF_FUN_PARAMS_SUPPORTED)
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace type_of
|
||||
{
|
||||
namespace
|
||||
{
|
||||
# define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPEOF_FUN_PARAMS_SUPPORTED)
|
||||
// BOOST_PP_FILENAME_1 is defined outside
|
||||
# include BOOST_PP_ITERATE()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif//BOOST_TYPEOF_REGISTER_FUNCTIONS_HPP_INCLUDED
|
25
include/boost/typeof/register_fundamental.hpp
Executable file
25
include/boost/typeof/register_fundamental.hpp
Executable file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_REGISTER_FUNDAMENTAL_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_REGISTER_FUNDAMENTAL_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(char);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(short);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(int);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(long);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(unsigned char);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(unsigned short);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(unsigned int);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(unsigned long);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(float);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(double);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(bool);
|
||||
BOOST_TYPEOF_REGISTER_TYPE(void);
|
||||
|
||||
#endif//BOOST_TYPEOF_REGISTER_FUNDAMENTAL_HPP_INCLUDED
|
83
include/boost/typeof/typeof.hpp
Executable file
83
include/boost/typeof/typeof.hpp
Executable file
@ -0,0 +1,83 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
|
||||
|
||||
// implementation
|
||||
|
||||
#include <boost/typeof/config.hpp>
|
||||
|
||||
// BOOST_TYPEOF, BOOST_TYPEOF_TPL
|
||||
|
||||
#if defined(BOOST_TYPEOF_COMPLIANT)
|
||||
# include <boost/typeof/compliant/typeof_impl.hpp>
|
||||
|
||||
#elif defined(BOOST_TYPEOF_VINTAGE)
|
||||
// include something to define BOOST_TYPEOF, BOOST_TYPEOF_TPL
|
||||
|
||||
#else//BOOST_TYPEOF_NATIVE
|
||||
|
||||
# if !defined BOOST_TYPEOF
|
||||
# define BOOST_TYPEOF __typeof__
|
||||
# endif
|
||||
# define BOOST_TYPEOF_TPL BOOST_TYPEOF
|
||||
|
||||
#endif
|
||||
|
||||
// auto
|
||||
|
||||
#define BOOST_AUTO(Var, Expr) BOOST_TYPEOF(Expr) Var(Expr)
|
||||
#define BOOST_AUTO_TPL(Var, Expr) BOOST_TYPEOF_TPL(Expr) Var(Expr)
|
||||
|
||||
// lvalue typeof
|
||||
|
||||
#if defined(BOOST_TYPEOF_VINTAGE)
|
||||
// include lvalue_typeof definition
|
||||
#else
|
||||
# include <boost/typeof/compliant/lvalue_typeof.hpp>
|
||||
#endif
|
||||
|
||||
// type/template encoding
|
||||
|
||||
#if defined(BOOST_TYPEOF_COMPLIANT)
|
||||
# include <boost/typeof/compliant/type_encoding.hpp>
|
||||
# include <boost/typeof/compliant/template_encoding.hpp>
|
||||
#elif defined(BOOST_TYPEOF_VINTAGE)
|
||||
// include type encoding definitions
|
||||
#else//BOOST_TYPEOF_NATIVE
|
||||
# define BOOST_TYPEOF_REGISTER_TYPE(x)
|
||||
# define BOOST_TYPEOF_REGISTER_TEMPLATE_X(x, params)
|
||||
#endif
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_TYPE_PARAM_(z, n, data) (typename)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE(Name, n)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X(Name,\
|
||||
BOOST_PP_REPEAT(n, BOOST_TYPEOF_REGISTER_TEMPLATE_TYPE_PARAM_, ~)\
|
||||
)
|
||||
|
||||
#define BOOST_TYPEOF_UNIQUE_ID()\
|
||||
BOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__
|
||||
|
||||
#define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\
|
||||
<boost/typeof/increment_registration_group.hpp>
|
||||
|
||||
// register stuff
|
||||
|
||||
#include <boost/typeof/register_fundamental.hpp>
|
||||
|
||||
#if defined(BOOST_TYPEOF_COMPLIANT)
|
||||
|
||||
# include <boost/typeof/compliant/modifiers.hpp>
|
||||
# include <boost/typeof/compliant/pointers_data_members.hpp>
|
||||
# define BOOST_PP_FILENAME_1 <boost/typeof/compliant/register_functions_iterate.hpp>
|
||||
# include <boost/typeof/register_functions.hpp>
|
||||
|
||||
#elif defined(BOOST_TYPEOF_VINTAGE)
|
||||
// include stuff here
|
||||
#else //BOOST_TYPEOF_NATIVE
|
||||
#endif
|
||||
|
||||
#endif//BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
|
323
test/compliant/main.cpp
Executable file
323
test/compliant/main.cpp
Executable file
@ -0,0 +1,323 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#pragma message("including typeof.hpp...")
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
#pragma message("done")
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#pragma message("registering")
|
||||
#include "stl/register.hpp"
|
||||
#include "mpl/register.hpp"
|
||||
#include "spirit/register.hpp"
|
||||
#include "lambda/register.hpp"
|
||||
#pragma message("done")
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/spirit.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include "typeid.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#pragma message("started")
|
||||
|
||||
double f_0()
|
||||
{
|
||||
cout << "functions with no params" << endl;
|
||||
return 0;
|
||||
}
|
||||
double f_9(int, double, short, char*, bool, char, float, long, unsigned short)
|
||||
{
|
||||
cout << "functions with 9 params" << endl;
|
||||
return 0;
|
||||
}
|
||||
void vf_0()
|
||||
{
|
||||
cout << "void functions with 0 params" << endl;
|
||||
}
|
||||
void vf_9(int, double, short, char*, bool, char, float, long, unsigned short)
|
||||
{
|
||||
cout << "void functions with 9 params" << endl;
|
||||
}
|
||||
|
||||
struct x
|
||||
{
|
||||
int f_0() volatile
|
||||
{
|
||||
cout << "member functions with no params" << endl;
|
||||
return 0;
|
||||
}
|
||||
int f_9(int, double, char, int, double, char, int, double, char)
|
||||
{
|
||||
cout << "member functions with 9 params" << endl;
|
||||
return 0;
|
||||
}
|
||||
void vf_0()
|
||||
{
|
||||
cout << "void member functions with no params" << endl;
|
||||
}
|
||||
void vf_9(int, double, char, int, double, char, int, double, char)
|
||||
{
|
||||
cout << "void member functions with 9 params" << endl;
|
||||
}
|
||||
int cf_0() const volatile
|
||||
{
|
||||
cout << "const member functions with no params" << endl;
|
||||
return 0;
|
||||
}
|
||||
int cf_9(int, double, char, int, double, char, int, double, char) const
|
||||
{
|
||||
cout << "const member functions with 9 params" << endl;
|
||||
return 0;
|
||||
}
|
||||
void cvf_0() const
|
||||
{
|
||||
cout << "const void member functions with no params" << endl;
|
||||
}
|
||||
void cvf_9(int, double, char, int, double, char, int, double, char) const
|
||||
{
|
||||
cout << "const void member functions with 9 params" << endl;
|
||||
}
|
||||
static void sf_0()
|
||||
{
|
||||
cout << "static member function" << endl;
|
||||
}
|
||||
std::vector<int> m_v;
|
||||
};
|
||||
|
||||
struct noncop : boost::noncopyable
|
||||
{};
|
||||
const noncop& foo_nc()
|
||||
{
|
||||
static noncop nc;
|
||||
return nc;
|
||||
}
|
||||
|
||||
template<class T, char c, unsigned short us,
|
||||
int i, unsigned long ul, bool b1, bool b2, unsigned u> struct with_integrals
|
||||
{};
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(x)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_X(with_integrals,
|
||||
(class)
|
||||
(char)
|
||||
(unsigned short)
|
||||
(int)
|
||||
(unsigned long)
|
||||
(bool)
|
||||
(bool)
|
||||
(unsigned)
|
||||
);
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(noncop)
|
||||
|
||||
main()
|
||||
{
|
||||
//#pragma message("integral...")
|
||||
// {
|
||||
// with_integrals<int, 5, 4, 3, 2, true, false, 5> expr;
|
||||
// BOOST_AUTO(v, expr);
|
||||
// v;
|
||||
// with_integrals<int, 1, 1, 0, ULONG_MAX, false, true, 0> expr1;
|
||||
// BOOST_AUTO(v1, expr1);
|
||||
// v1;
|
||||
// }
|
||||
#pragma message("Noncopyable...")
|
||||
{
|
||||
//BOOST_AUTO(v, foo_nc());
|
||||
BOOST_AUTO(const& v, foo_nc());
|
||||
}
|
||||
#pragma message("Lvalue preserving...")
|
||||
{
|
||||
int n;
|
||||
const int cn = 0;
|
||||
int& rn = n;
|
||||
const int& rcn = cn;
|
||||
int f();
|
||||
//const int cf();
|
||||
int& rf();
|
||||
const int& rcf();
|
||||
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(n)>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(cn)>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(rn)>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(rcn)>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(f())>::name() << endl;
|
||||
//cout << type_id<BOOST_LVALUE_TYPEOF(cf())>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(rf())>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(rcf())>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(21)>::name() << endl;
|
||||
cout << type_id<BOOST_LVALUE_TYPEOF(int(21))>::name() << endl;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(n), int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cn), const int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rn), int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcn), const int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(f()), int>::value));
|
||||
//BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cf()), const int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rf()), int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcf()), const int&>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(21), int>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(int(21)), int>::value));
|
||||
}
|
||||
#pragma message("compiling Lambda example...")
|
||||
{
|
||||
using namespace boost::lambda;
|
||||
|
||||
BOOST_AUTO(fun, _1 > 15 && _2 < 20);
|
||||
int n = 19;
|
||||
assert(fun(n, n));
|
||||
|
||||
std::cout << typeid(fun).name() << std::endl;
|
||||
}
|
||||
#pragma message("compiling Spirit example...")
|
||||
{
|
||||
// spirit example
|
||||
|
||||
using namespace boost::spirit;
|
||||
using namespace boost::lambda;
|
||||
using namespace std;
|
||||
|
||||
vector<double> v;
|
||||
|
||||
BOOST_AUTO(parser,
|
||||
(real_p[push_back_a(v)] >> *(',' >> real_p[push_back_a(v)]))
|
||||
);
|
||||
|
||||
parse("3.14159, 2.71828", parser, space_p);
|
||||
|
||||
for_each(v.begin(), v.end(), cout << _1 << ' ');
|
||||
cout << endl;
|
||||
}
|
||||
#pragma message("compiling another Spirit example...")
|
||||
{
|
||||
// more spirit...
|
||||
|
||||
using namespace boost::spirit;
|
||||
|
||||
BOOST_AUTO(
|
||||
skipper,
|
||||
( space_p
|
||||
| "//" >> *(anychar_p - '\n') >> '\n'
|
||||
| "/*" >> *(anychar_p - "*/") >> "*/"
|
||||
)
|
||||
);
|
||||
|
||||
bool success = parse(
|
||||
"/*this is a comment*/\n//this is a c++ comment\n\n",
|
||||
*skipper).full;
|
||||
|
||||
assert(success);
|
||||
}
|
||||
#pragma message("compiling Modifiers example...")
|
||||
{
|
||||
//modifiers
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
// top-level pointers are preserved...
|
||||
|
||||
mpl::vector3<const int* const, const int[20], const int&>* foo();
|
||||
cout << typeid(BOOST_TYPEOF(foo())).name() << endl;
|
||||
|
||||
// ... but top-level refs are not :(
|
||||
|
||||
mpl::vector2<const int* const, const int&>& bar();
|
||||
cout << typeid(BOOST_TYPEOF(bar())).name() << endl;
|
||||
|
||||
mpl::vector1<int[5]> vi;
|
||||
cout << "int[5]" << endl;
|
||||
cout << typeid(BOOST_TYPEOF(vi)).name() << endl;
|
||||
|
||||
mpl::vector1<const int[5]> vci;
|
||||
cout << "const int[5]" << endl;
|
||||
cout << typeid(BOOST_TYPEOF(vci)).name() << endl;
|
||||
}
|
||||
#pragma message("compiling functions example...")
|
||||
{
|
||||
BOOST_AUTO(p0, &f_0);
|
||||
(*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &f_9);
|
||||
(*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling void functions example...")
|
||||
{
|
||||
BOOST_AUTO(p0, &vf_0);
|
||||
(*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &vf_9);
|
||||
(*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling member functions example...")
|
||||
{
|
||||
x xx;
|
||||
|
||||
BOOST_AUTO(p0, &x::f_0);
|
||||
(xx.*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &x::f_9);
|
||||
(xx.*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling void member functions example...")
|
||||
{
|
||||
x xx;
|
||||
|
||||
BOOST_AUTO(p0, &x::vf_0);
|
||||
(xx.*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &x::vf_9);
|
||||
(xx.*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling const member functions example...")
|
||||
{
|
||||
x xx;
|
||||
|
||||
BOOST_AUTO(p0, &x::cf_0);
|
||||
(xx.*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &x::cf_9);
|
||||
(xx.*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling const void member functions example...")
|
||||
{
|
||||
x xx;
|
||||
|
||||
BOOST_AUTO(p0, &x::cvf_0);
|
||||
(xx.*p0)();
|
||||
|
||||
BOOST_AUTO(p9, &x::cvf_9);
|
||||
(xx.*p9)(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#pragma message("compiling static member functions example...")
|
||||
{
|
||||
BOOST_AUTO(p0, &x::sf_0);
|
||||
(*p0)();
|
||||
}
|
||||
#pragma message("pointers to data members...")
|
||||
{
|
||||
BOOST_AUTO(p, &x::m_v);
|
||||
x xx;
|
||||
(xx.*p).push_back(1);
|
||||
}
|
||||
#pragma message("ODR")
|
||||
|
||||
void odr_test1();
|
||||
void odr_test2();
|
||||
odr_test1();
|
||||
odr_test2();
|
||||
|
||||
#pragma message("done!")
|
||||
}
|
||||
|
48
test/compliant/odr.hpp
Executable file
48
test/compliant/odr.hpp
Executable file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef ODR_HPP_INCLUDED
|
||||
#define ODR_HPP_INCLUDED
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
void odr_test1();
|
||||
void odr_test2();
|
||||
|
||||
// trying to cause ODR violation in a class template
|
||||
|
||||
template<class T, class U>
|
||||
class sum_t
|
||||
{
|
||||
public:
|
||||
typedef BOOST_TYPEOF_TPL(T() + U()) result_type;
|
||||
|
||||
sum_t(const T& t, const U& u)
|
||||
: m_sum(t + u)
|
||||
{}
|
||||
BOOST_TYPEOF_TPL(T() + U()) operator()()
|
||||
{
|
||||
BOOST_AUTO_TPL(result, m_sum);
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
BOOST_TYPEOF_TPL(T() + U()) m_sum;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
sum_t<T, U> make_sum(const T& t, const U& u)
|
||||
{
|
||||
return sum_t<T, U>(t, u);
|
||||
}
|
||||
|
||||
// trying to cause ODR violation in a function template
|
||||
|
||||
template<class T, class U>
|
||||
typename sum_t<T, U>::result_type sum(const T& t, const U& u)
|
||||
{
|
||||
BOOST_AUTO_TPL(result, t + u);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif//ODR_HPP_INCLUDED
|
18
test/compliant/odr1.cpp
Executable file
18
test/compliant/odr1.cpp
Executable file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <iostream>
|
||||
#include "odr.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void odr_test1()
|
||||
{
|
||||
char i = 5;
|
||||
double d = 3.14;
|
||||
cout << sum(d, i) << endl;
|
||||
cout << sum(i, d) << endl;
|
||||
cout << make_sum(d, i)() << endl;
|
||||
cout << make_sum(i, d)() << endl;
|
||||
}
|
18
test/compliant/odr2.cpp
Executable file
18
test/compliant/odr2.cpp
Executable file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <iostream>
|
||||
#include "odr.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void odr_test2()
|
||||
{
|
||||
char i = 5;
|
||||
double d = 3.14;
|
||||
cout << sum(d, i) << endl;
|
||||
cout << sum(i, d) << endl;
|
||||
cout << make_sum(d, i)() << endl;
|
||||
cout << make_sum(i, d)() << endl;
|
||||
}
|
33
test/compliant/typeid.hpp
Executable file
33
test/compliant/typeid.hpp
Executable file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef TYPEID_HPP_INCLUDED
|
||||
#define TYPEID_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
template<class T> struct type_id
|
||||
{
|
||||
static std::string name()
|
||||
{
|
||||
return typeid(T).name();
|
||||
}
|
||||
};
|
||||
template<class T> struct type_id<T&>
|
||||
{
|
||||
static std::string name()
|
||||
{
|
||||
return type_id<T>::name() + "&";
|
||||
}
|
||||
};
|
||||
template<class T> struct type_id<const T>
|
||||
{
|
||||
static std::string name()
|
||||
{
|
||||
return std::string("const ") + type_id<T>::name();
|
||||
}
|
||||
};
|
||||
|
||||
#endif//TYPEID_HPP_INCLUDED
|
||||
|
21
test/compliant/typeof.sln
Executable file
21
test/compliant/typeof.sln
Executable file
@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "typeof", "typeof.vcproj", "{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}.Debug.ActiveCfg = Debug|Win32
|
||||
{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}.Debug.Build.0 = Debug|Win32
|
||||
{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}.Release.ActiveCfg = Release|Win32
|
||||
{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
217
test/compliant/typeof.vcproj
Executable file
217
test/compliant/typeof.vcproj
Executable file
@ -0,0 +1,217 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="typeof"
|
||||
ProjectGUID="{5C140C9B-1EF9-483D-92CB-86A1108AA7BF}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/typeof.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/typeof.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="C:\boost\boost_1_32_0;../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/typeof.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\main.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\odr1.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\odr2.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\concatenate.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\config.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\encode_decode.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\increment_registration_group.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\int_encoding.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\limit_size.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\lvalue_typeof.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\modifiers.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\odr.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\pointers_data_members.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\register_functions.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\register_functions_iterate.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\register_fundamental.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\register_mem_functions.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\template_encoding.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\type_encoding.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\typeof.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\typeof\compliant\typeof_impl.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="spirit"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\spirit\register.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="lambda"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\lambda\register.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="stl"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\stl\register.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="mpl"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\mpl\register.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
2
test/compliant/typeof_g++.bat
Executable file
2
test/compliant/typeof_g++.bat
Executable file
@ -0,0 +1,2 @@
|
||||
g++ -IC:\boost\boost_1_32_0 -I..\..\..\.. -D BOOST_TYPEOF_FORCE_EMULATION -D BOOST_TYPEOF_LIMIT_SIZE=50 -D BOOST_MPL_LIMIT_VECTOR_SIZE=50 odr1.cpp odr2.cpp main.cpp
|
||||
g++ -IC:\boost\boost_1_32_0 -I..\..\..\.. odr1.cpp odr2.cpp main.cpp
|
Reference in New Issue
Block a user