mirror of
https://github.com/boostorg/typeof.git
synced 2025-07-31 05:17:24 +02:00
added NO_SIMPLE_TYPE_OPTIMIZATION workaround for vc8
[SVN r2607]
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#define BOOST_TYPEOF_CONFIG_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_TYPEOF_COMPLIANT) &&\
|
||||
!defined(BOOST_TYPEOF_NATIVE)
|
||||
@ -27,4 +28,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# define BOOST_TYPEOF_NO_SIMPLE_TYPE_OPTIMIZATION
|
||||
#endif
|
||||
|
||||
#endif//BOOST_TYPEOF_CONFIG_HPP_INCLUDED
|
||||
|
@ -9,12 +9,13 @@
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
#include <boost/typeof/encode_decode.hpp>
|
||||
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
|
||||
#ifdef BOOST_TYPEOF_USE_MPL_VECTOR
|
||||
# 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/typeof/limit_size.hpp>
|
||||
# define BOOST_TYPEOF_VECTOR(n) BOOST_PP_CAT(boost::mpl::vector, n)
|
||||
#else
|
||||
@ -25,9 +26,21 @@
|
||||
namespace boost{namespace type_of{
|
||||
|
||||
template<int pos, class T>
|
||||
char(&at(const T&))[
|
||||
mpl::at<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type, mpl::int_<pos> >::type::value
|
||||
struct at_result
|
||||
{
|
||||
typedef typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type encoded_type;
|
||||
typedef typename mpl::size<encoded_type>::type size;
|
||||
|
||||
typedef char(&type)[
|
||||
mpl::at<
|
||||
encoded_type,
|
||||
mpl::int_<(pos < size::value) ? pos : 0>
|
||||
>::type::value
|
||||
];
|
||||
};
|
||||
|
||||
template<int pos, class T>
|
||||
typename at_result<pos, T>::type at(const T&);
|
||||
|
||||
template<class T>
|
||||
char(&size(const T&))[
|
||||
@ -38,8 +51,13 @@ namespace boost{namespace type_of{
|
||||
#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)\
|
||||
#ifndef BOOST_TYPEOF_NO_SIMPLE_TYPE_OPTIMIZATION
|
||||
# define BOOST_TYPEOF_TYPEITEM(z, n, expr)\
|
||||
boost::mpl::size_t<BOOST_TYPEOF_AT((n < BOOST_TYPEOF_SIZE(expr)) ? n : 0, expr)>
|
||||
#else
|
||||
# define BOOST_TYPEOF_TYPEITEM(z, n, expr)\
|
||||
boost::mpl::size_t<BOOST_TYPEOF_AT(n, expr)>
|
||||
#endif
|
||||
|
||||
#define BOOST_TYPEOF(Expr) \
|
||||
boost::type_of::decode_type< \
|
||||
|
@ -96,4 +96,20 @@ namespace negate_test
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_TYPEOF_TEXT "adder..."
|
||||
#include <boost/typeof/message.hpp>
|
||||
|
||||
namespace test_adder
|
||||
{
|
||||
template<class T> T make();
|
||||
|
||||
template<class T, class U>
|
||||
struct adder
|
||||
{
|
||||
typedef BOOST_TYPEOF_TPL(make<T>() + make<U>()) type;
|
||||
};
|
||||
|
||||
typedef adder<int, double>::type type;
|
||||
};
|
||||
|
||||
#endif//!(BOOST_WORKAROUND(BOOST_MSVC, <= 1300))
|
||||
|
Reference in New Issue
Block a user