compiler-dependent config

[SVN r31137]
This commit is contained in:
Arkadiy Vertleyb
2005-09-28 03:47:05 +00:00
parent 92e77f51d6
commit 506c77897d
3 changed files with 129 additions and 100 deletions

View File

@@ -1,35 +0,0 @@
// 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
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#if !defined(BOOST_TYPEOF_COMPLIANT) &&\
!defined(BOOST_TYPEOF_NATIVE)
# if defined __GNUC__
# define BOOST_TYPEOF_NATIVE
# elif defined __MWERKS__
# define BOOST_TYPEOF_NATIVE
# elif defined(BOOST_MSVC) && (BOOST_MSVC<1400)
//Doesn't require registration
# define BOOST_TYPEOF_NATIVE
# else
# define BOOST_TYPEOF_COMPLIANT
# endif
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
# define BOOST_TYPEOF_NO_SIMPLE_TYPE_OPTIMIZATION
#endif
#endif//BOOST_TYPEOF_CONFIG_HPP_INCLUDED

View File

@@ -14,6 +14,7 @@
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/seq/transform.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/seq/cat.hpp>
#include <boost/typeof/encode_decode.hpp>
#include <boost/typeof/int_encoding.hpp>

View File

@@ -5,85 +5,148 @@
#ifndef BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
#define BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/cat.hpp>
#include <boost/preprocessor/expand.hpp>
#if defined(BOOST_TYPEOF_COMPLIANT)
# define BOOST_TYPEOF_EMULATION
#endif
// implementation
#if defined(BOOST_TYPEOF_EMULATION) && defined(BOOST_TYPEOF_NATIVE)
# error both typeof emulation and native mode requested
#endif
#include <boost/typeof/config.hpp>
#if defined(__COMO__)
# ifdef __GNUG__
# ifndef(BOOST_TYPEOF_EMULATION)
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# define BOOST_TYPEOF_KEYWORD typeof
# endif
# else
# ifndef BOOST_TYPEOF_NATIVE
# ifndef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_EMULATION
# endif
# else
# error native typeof is not supported
# endif
# endif
// BOOST_TYPEOF, BOOST_TYPEOF_TPL
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
# ifdef __GNUC__
# ifndef BOOST_TYPEOF_EMULATION
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# define BOOST_TYPEOF_KEYWORD __typeof__
# endif
# else
# ifndef BOOST_TYPEOF_NATIVE
# ifndef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_EMULATION
# endif
# else
# error native typeof is not supported
# endif
# endif
#if defined(BOOST_TYPEOF_NATIVE) && defined(BOOST_MSVC)
# define BOOST_TYPEOF_TEXT "using msvc 'native' imlementation"
# include <boost/typeof/message.hpp>
# include <boost/typeof/msvc/typeof_impl.hpp>
#elif defined(__GNUC__)
# ifndef BOOST_TYPEOF_EMULATION
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# define BOOST_TYPEOF_KEYWORD __typeof__
# endif
#elif defined(BOOST_TYPEOF_COMPLIANT)
# define BOOST_TYPEOF_TEXT "using compliant imlementation"
# include <boost/typeof/message.hpp>
# include <boost/typeof/typeof_impl.hpp>
#elif defined(__MWERKS__)
# ifndef BOOST_TYPEOF_EMULATION
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# define BOOST_TYPEOF_KEYWORD __typeof__
# endif
#else//BOOST_TYPEOF_NATIVE
#elif defined(_MSC_VER)
# if (_MSC_VER <= 1300) // 6.5, 7.0
# ifndef BOOST_TYPEOF_EMULATION
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# include <boost/typeof/msvc/typeof_impl.hpp>
# define MSVC_TYPEOF_HACK
# else
# error typeof emulation is not supported
# endif
# elif (_MSC_VER == 1310) // 7.1
# ifndef BOOST_TYPEOF_EMULATION
# ifndef BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_NATIVE
# endif
# include <boost/typeof/msvc/typeof_impl.hpp>
# define MSVC_TYPEOF_HACK
# endif
# else // 8.0
# ifndef BOOST_TYPEOF_NATIVE
# ifndef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_EMULATION
# endif
# else
# error native typeof is not supported
# endif
# endif
# define BOOST_TYPEOF_TEXT "using native imlementation"
# include <boost/typeof/message.hpp>
# if !defined BOOST_TYPEOF_KEYWORD
# define BOOST_TYPEOF_KEYWORD typeof
# endif
/* Native typeof can accept either type or value.
Something like "int()" can be viewed either way, but
typeof consideres it a type. We force it otherwise
to ensure consistensy with emulation */
namespace boost { namespace type_of {
template<class T> T& ensure_obj(const T&);
}}
# define BOOST_TYPEOF(expr) BOOST_TYPEOF_KEYWORD(boost::type_of::ensure_obj(expr))
# define BOOST_TYPEOF_TPL BOOST_TYPEOF
#else //unknown compiler
# ifndef BOOST_TYPEOF_NATIVE
# ifndef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_EMULATION
# endif
# else
# ifndef BOOST_TYPEOF_KEYWORD
# define BOOST_TYPEOF_KEYWORD typeof
# endif
# endif
#endif
#define BOOST_TYPEOF_UNIQUE_ID()\
BOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__
#define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\
<boost/typeof/increment_registration_group.hpp>
#ifdef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_TEXT "using typeof emulation"
# include <boost/typeof/typeof_impl.hpp>
# include <boost/typeof/type_encoding.hpp>
# include <boost/typeof/template_encoding.hpp>
# include <boost/typeof/modifiers.hpp>
# include <boost/typeof/pointers_data_members.hpp>
# include <boost/typeof/register_functions.hpp>
# include <boost/typeof/register_fundamental.hpp>
#elif defined(BOOST_TYPEOF_NATIVE)
# define BOOST_TYPEOF_TEXT "using native typeof"
# ifndef MSVC_TYPEOF_HACK
namespace boost { namespace type_of {
template<class T> T& ensure_obj(const T&);
}}
# define BOOST_TYPEOF(expr) BOOST_TYPEOF_KEYWORD(boost::type_of::ensure_obj(expr))
# define BOOST_TYPEOF_TPL BOOST_TYPEOF
# endif
# define BOOST_TYPEOF_REGISTER_TYPE(x)
# define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params)
#else
# error typeof configuration error
#endif
#include <boost/typeof/message.hpp>
// 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
# include <boost/typeof/lvalue_typeof.hpp>
// type/template encoding
#if defined(BOOST_TYPEOF_COMPLIANT)
# include <boost/typeof/type_encoding.hpp>
# include <boost/typeof/template_encoding.hpp>
#else //BOOST_TYPEOF_NATIVE
# define BOOST_TYPEOF_REGISTER_TYPE(x)
# define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params)
#endif
#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/modifiers.hpp>
# include <boost/typeof/pointers_data_members.hpp>
# include <boost/typeof/register_functions.hpp>
#else //BOOST_TYPEOF_NATIVE
#endif
#include <boost/typeof/lvalue_typeof.hpp>
#endif//BOOST_TYPEOF_TYPEOF_HPP_INCLUDED