From 81e54ccb1f8de10303ab7d6dab91e047824f23d5 Mon Sep 17 00:00:00 2001 From: Peder Holt Date: Thu, 21 Oct 2010 09:34:15 +0000 Subject: [PATCH] Integrated from trunk: #4593 Type_of does not use BOOST_TYPEOF_EMULATION for VC10 and \Za #3520 Syntax Error in boost/typeof/typeof.hpp #4605 Make BOOST_TYPEOF_SILENT default Apply variadic functions patch from Sergey Zubkovsky. Allow inclusion of typeof.hpp for compilers (borland) that does not support typeof emulation or native typeof. For these compilers, BOOST_TYPEOF_EMULATION_UNSUPPORTED will be defined, and BOOST_TYPEOF(Expr) will always result in boost::type_of::typeof_emulation_is_unsupported_on_this_compiler [SVN r66130] --- include/boost/typeof/message.hpp | 2 +- include/boost/typeof/register_functions.hpp | 19 +++++--- .../typeof/register_functions_iterate.hpp | 48 +++++++++++++++++++ include/boost/typeof/typeof.hpp | 44 +++++++++++------ 4 files changed, 91 insertions(+), 22 deletions(-) mode change 100755 => 100644 include/boost/typeof/message.hpp mode change 100755 => 100644 include/boost/typeof/register_functions.hpp mode change 100755 => 100644 include/boost/typeof/register_functions_iterate.hpp mode change 100755 => 100644 include/boost/typeof/typeof.hpp diff --git a/include/boost/typeof/message.hpp b/include/boost/typeof/message.hpp old mode 100755 new mode 100644 index 1471ef3..cabbb82 --- a/include/boost/typeof/message.hpp +++ b/include/boost/typeof/message.hpp @@ -2,7 +2,7 @@ // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) -#if defined(_MSC_VER) && !defined BOOST_TYPEOF_SILENT +#if defined(_MSC_VER) && defined BOOST_TYPEOF_MESSAGES # pragma message(BOOST_TYPEOF_TEXT) #endif #undef BOOST_TYPEOF_TEXT diff --git a/include/boost/typeof/register_functions.hpp b/include/boost/typeof/register_functions.hpp old mode 100755 new mode 100644 index 2af7cec..407bba3 --- a/include/boost/typeof/register_functions.hpp +++ b/include/boost/typeof/register_functions.hpp @@ -24,12 +24,19 @@ enum { FUN_ID = BOOST_TYPEOF_UNIQUE_ID(), - FUN_PTR_ID = FUN_ID + 1 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), - FUN_REF_ID = FUN_ID + 2 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), - MEM_FUN_ID = FUN_ID + 3 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), - CONST_MEM_FUN_ID = FUN_ID + 4 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), - VOLATILE_MEM_FUN_ID = FUN_ID + 5 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), - VOLATILE_CONST_MEM_FUN_ID = FUN_ID + 6 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY) + FUN_PTR_ID = FUN_ID + 1 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + FUN_REF_ID = FUN_ID + 2 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + MEM_FUN_ID = FUN_ID + 3 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + CONST_MEM_FUN_ID = FUN_ID + 4 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + VOLATILE_MEM_FUN_ID = FUN_ID + 5 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + VOLATILE_CONST_MEM_FUN_ID = FUN_ID + 6 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + FUN_VAR_ID = FUN_ID + 7 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + FUN_VAR_PTR_ID = FUN_ID + 8 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + FUN_VAR_REF_ID = FUN_ID + 9 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + MEM_FUN_VAR_ID = FUN_ID + 10 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + CONST_MEM_FUN_VAR_ID = FUN_ID + 11 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + VOLATILE_MEM_FUN_VAR_ID = FUN_ID + 12 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY), + VOLATILE_CONST_MEM_FUN_VAR_ID = FUN_ID + 13 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY) }; BOOST_TYPEOF_BEGIN_ENCODE_NS diff --git a/include/boost/typeof/register_functions_iterate.hpp b/include/boost/typeof/register_functions_iterate.hpp old mode 100755 new mode 100644 index b1048ad..aaa43f3 --- a/include/boost/typeof/register_functions_iterate.hpp +++ b/include/boost/typeof/register_functions_iterate.hpp @@ -15,6 +15,13 @@ struct encode_type_impl typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_PTR_ID + n) type; }; +template +struct encode_type_impl +{ + typedef R BOOST_PP_CAT(P, n); + typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type; +}; + template struct decode_type_impl, Iter> { @@ -24,6 +31,15 @@ struct decode_type_impl, Iter> typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter; }; +template +struct decode_type_impl, 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; +}; + #ifndef BOOST_TYPEOF_NO_FUNCTION_TYPES // function references @@ -35,6 +51,13 @@ struct decode_type_impl, Iter> typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_REF_ID + n) type; }; + template + struct encode_type_impl + { + typedef R BOOST_PP_CAT(P, n); + typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_REF_ID + n) type; + }; + template struct decode_type_impl, Iter> { @@ -44,6 +67,15 @@ struct decode_type_impl, Iter> typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter; }; + template + struct decode_type_impl, 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; + }; + // functions template @@ -53,6 +85,13 @@ struct decode_type_impl, Iter> typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_ID + n) type; }; + template + struct encode_type_impl + { + typedef R BOOST_PP_CAT(P, n); + typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_ID + n) type; + }; + template struct decode_type_impl, Iter> { @@ -62,6 +101,15 @@ struct decode_type_impl, Iter> typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter; }; + template + struct decode_type_impl, 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; + }; + #endif//BOOST_TYPEOF_NO_FUNCTION_TYPES #ifndef BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES diff --git a/include/boost/typeof/typeof.hpp b/include/boost/typeof/typeof.hpp old mode 100755 new mode 100644 index 165ef95..3e91649 --- a/include/boost/typeof/typeof.hpp +++ b/include/boost/typeof/typeof.hpp @@ -15,7 +15,7 @@ #if defined(__COMO__) # ifdef __GNUG__ -# ifndef(BOOST_TYPEOF_EMULATION) +# ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE # define BOOST_TYPEOF_NATIVE # endif @@ -65,7 +65,7 @@ # endif # define BOOST_TYPEOF_KEYWORD __typeof__ # else -# error typeof emulation is not supported +# define BOOST_TYPEOF_EMULATION_UNSUPPORTED # endif # else // 9.x # ifndef BOOST_TYPEOF_EMULATION @@ -75,7 +75,22 @@ # define BOOST_TYPEOF_KEYWORD __typeof__ # endif # endif - +#elif defined __CODEGEARC__ +# ifndef BOOST_TYPEOF_EMULATION +# ifndef BOOST_TYPEOF_NATIVE +# define BOOST_TYPEOF_EMULATION_UNSUPPORTED +# endif +# else +# define BOOST_TYPEOF_EMULATION_UNSUPPORTED +# endif +#elif defined __BORLANDC__ +# ifndef BOOST_TYPEOF_EMULATION +# ifndef BOOST_TYPEOF_NATIVE +# define BOOST_TYPEOF_EMULATION_UNSUPPORTED +# endif +# else +# define BOOST_TYPEOF_EMULATION_UNSUPPORTED +# endif #elif defined __DMC__ # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE @@ -95,24 +110,21 @@ # else # error typeof emulation is not supported # endif -# elif (_MSC_VER >= 1310) // 7.1, 8.0 +# elif (_MSC_VER >= 1310) // 7.1 -> # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE -# define BOOST_TYPEOF_NATIVE +# ifndef _MSC_EXTENSIONS +# define BOOST_TYPEOF_EMULATION +# else +# define BOOST_TYPEOF_NATIVE +# endif # endif +# endif +# ifdef BOOST_TYPEOF_NATIVE # include # 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 - #elif defined(__HP_aCC) # ifndef BOOST_TYPEOF_NATIVE # ifndef BOOST_TYPEOF_EMULATION @@ -163,7 +175,9 @@ #define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\ -#ifdef BOOST_TYPEOF_EMULATION +#ifdef BOOST_TYPEOF_EMULATION_UNSUPPORTED +# include +#elif defined BOOST_TYPEOF_EMULATION # define BOOST_TYPEOF_TEXT "using typeof emulation" # include # include