diff options
Diffstat (limited to 'boost/typeof')
-rw-r--r-- | boost/typeof/decltype.hpp | 34 | ||||
-rw-r--r-- | boost/typeof/msvc/typeof_impl.hpp | 90 | ||||
-rw-r--r--[-rwxr-xr-x] | boost/typeof/native.hpp | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | boost/typeof/register_fundamental.hpp | 3 | ||||
-rw-r--r-- | boost/typeof/typeof.hpp | 37 |
5 files changed, 63 insertions, 101 deletions
diff --git a/boost/typeof/decltype.hpp b/boost/typeof/decltype.hpp new file mode 100644 index 0000000000..7e990a8cef --- /dev/null +++ b/boost/typeof/decltype.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2006 Arkadiy Vertleyb +// Copyright (C) 2017 Daniela Engert +// 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_DECLTYPE_HPP_INCLUDED +# define BOOST_TYPEOF_DECLTYPE_HPP_INCLUDED + +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> + +namespace boost { namespace type_of { + template<typename T> + using remove_cv_ref_t = typename remove_cv<typename remove_reference<T>::type>::type; +}} + +#define BOOST_TYPEOF(expr) boost::type_of::remove_cv_ref_t<decltype(expr)> +#define BOOST_TYPEOF_TPL BOOST_TYPEOF + +#define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF_TPL(expr) type;\ + }; + +#define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF(expr) type;\ + }; + +#define BOOST_TYPEOF_REGISTER_TYPE(x) +#define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params) + +#endif //BOOST_TYPEOF_DECLTYPE_HPP_INCLUDED + diff --git a/boost/typeof/msvc/typeof_impl.hpp b/boost/typeof/msvc/typeof_impl.hpp index 74ebc70738..3071efb749 100644 --- a/boost/typeof/msvc/typeof_impl.hpp +++ b/boost/typeof/msvc/typeof_impl.hpp @@ -15,9 +15,7 @@ # include <boost/type_traits/is_function.hpp> # include <boost/utility/enable_if.hpp> -# if BOOST_WORKAROUND(BOOST_MSVC,>=1310) -# include <typeinfo> -# endif +# include <typeinfo> namespace boost { @@ -25,7 +23,7 @@ namespace boost { //Compile time constant code -# if BOOST_WORKAROUND(BOOST_MSVC,>=1300) && defined(_MSC_EXTENSIONS) +# if defined(_MSC_EXTENSIONS) template<int N> struct the_counter; template<typename T,int N = 5/*for similarity*/> @@ -85,26 +83,7 @@ namespace boost //Typeof code -# if BOOST_WORKAROUND(BOOST_MSVC,==1300) - template<typename ID> - struct msvc_extract_type - { - template<bool> - struct id2type_impl; - - typedef id2type_impl<true> id2type; - }; - - template<typename T, typename ID> - struct msvc_register_type : msvc_extract_type<ID> - { - template<> - struct id2type_impl<true> //VC7.0 specific bugfeature - { - typedef T type; - }; - }; -#elif BOOST_WORKAROUND(BOOST_MSVC,>=1400) +# if BOOST_WORKAROUND(BOOST_MSVC,>=1400) struct msvc_extract_type_default_param {}; template<typename ID, typename T = msvc_extract_type_default_param> @@ -153,60 +132,7 @@ namespace boost }; }; # endif -// EAN: preprocess this block out on advice of Peder Holt -// to eliminate errors in type_traits/common_type.hpp -# if 0 //BOOST_WORKAROUND(BOOST_MSVC,==1310) - template<const std::type_info& ref_type_info> - struct msvc_typeid_wrapper { - typedef typename msvc_extract_type<msvc_typeid_wrapper>::id2type id2type; - typedef typename id2type::type wrapped_type; - typedef typename wrapped_type::type type; - }; - //This class is used for registering the type T. encode_type<T> is mapped against typeid(encode_type<T>). - //msvc_typeid_wrapper<typeid(encode_type<T>)> will now have a type typedef that equals encode_type<T>. - template<typename T> - struct encode_type - { - typedef encode_type<T> input_type; - //Invoke registration of encode_type<T>. typeid(encode_type<T>) is now mapped to encode_type<T>. Do not use registered_type for anything. - //The reason for registering encode_type<T> rather than T, is that VC handles typeid(function reference) poorly. By adding another - //level of indirection, we solve this problem. - typedef typename msvc_register_type<input_type,msvc_typeid_wrapper<typeid(input_type)> >::id2type registered_type; - typedef T type; - }; - - template<typename T> typename disable_if< - typename is_function<T>::type, - typename encode_type<T>::input_type>::type encode_start(T const&); - - template<typename T> typename enable_if< - typename is_function<T>::type, - typename encode_type<T>::input_type>::type encode_start(T&); - - template<typename Organizer, typename T> - msvc_register_type<T,Organizer> typeof_register_type(const T&); - - -# define BOOST_TYPEOF(expr) \ - boost::type_of::msvc_typeid_wrapper<typeid(boost::type_of::encode_start(expr))>::type - -# define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr) -# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ -struct name {\ - enum {_typeof_register_value=sizeof(typeid(boost::type_of::typeof_register_type<name>(expr)))};\ - typedef typename boost::type_of::msvc_extract_type<name>::id2type id2type;\ - typedef typename id2type::type type;\ -}; - -# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ -struct name {\ - enum {_typeof_register_value=sizeof(typeid(boost::type_of::typeof_register_type<name>(expr)))};\ - typedef boost::type_of::msvc_extract_type<name>::id2type id2type;\ - typedef id2type::type type;\ -}; - -# else template<int ID> struct msvc_typeid_wrapper { typedef typename msvc_extract_type<mpl::int_<ID> >::id2type id2type; @@ -242,7 +168,6 @@ struct name {\ { typedef char(*type)[encode_type<T>::value]; }; -# if BOOST_WORKAROUND(BOOST_MSVC,>=1310) template<typename T> typename disable_if< typename is_function<T>::type, typename sizer<T>::type>::type encode_start(T const&); @@ -250,10 +175,6 @@ struct name {\ template<typename T> typename enable_if< typename is_function<T>::type, typename sizer<T>::type>::type encode_start(T&); -# else - template<typename T> - typename sizer<T>::type encode_start(T const&); -# endif template<typename Organizer, typename T> msvc_register_type<T,Organizer> typeof_register_type(const T&,Organizer* =0); @@ -264,19 +185,18 @@ struct name {\ # define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ struct name {\ - BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr)));\ + enum {_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr))};\ typedef typename boost::type_of::msvc_extract_type<name>::id2type id2type;\ typedef typename id2type::type type;\ }; # define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ struct name {\ - BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr)));\ + enum {_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr))};\ typedef boost::type_of::msvc_extract_type<name>::id2type id2type;\ typedef id2type::type type;\ }; -#endif } } diff --git a/boost/typeof/native.hpp b/boost/typeof/native.hpp index 8197e28669..8197e28669 100755..100644 --- a/boost/typeof/native.hpp +++ b/boost/typeof/native.hpp diff --git a/boost/typeof/register_fundamental.hpp b/boost/typeof/register_fundamental.hpp index 3a15888d08..a6164bafa3 100755..100644 --- a/boost/typeof/register_fundamental.hpp +++ b/boost/typeof/register_fundamental.hpp @@ -34,8 +34,7 @@ BOOST_TYPEOF_REGISTER_TYPE(long double) BOOST_TYPEOF_REGISTER_TYPE(wchar_t) #endif -#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1200)) \ - || (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \ +#if (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \ || (defined(__BORLANDC__) && (__BORLANDC__ == 0x600) && (_MSC_VER == 1200)) BOOST_TYPEOF_REGISTER_TYPE(unsigned __int8) BOOST_TYPEOF_REGISTER_TYPE(__int8) diff --git a/boost/typeof/typeof.hpp b/boost/typeof/typeof.hpp index 4d56964980..1efa3dc8c4 100644 --- a/boost/typeof/typeof.hpp +++ b/boost/typeof/typeof.hpp @@ -13,7 +13,15 @@ # error both typeof emulation and native mode requested #endif -#if defined(__COMO__) +#include <boost/config.hpp> + +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION) +# define BOOST_TYPEOF_DECLTYPE +# ifndef BOOST_TYPEOF_NATIVE +# define BOOST_TYPEOF_NATIVE +# endif + +#elif defined(__COMO__) # ifdef __GNUG__ # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE @@ -49,7 +57,7 @@ # endif # endif -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE # define BOOST_TYPEOF_NATIVE @@ -100,17 +108,7 @@ # define MSVC_TYPEOF_HACK # endif #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 -> +# if (_MSC_VER >= 1310) // 7.1 -> # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE # ifndef _MSC_EXTENSIONS @@ -171,6 +169,13 @@ # define BOOST_TYPEOF_KEYWORD __typeof__ # endif # endif +#elif defined(__IBM__TYPEOF__) +# ifndef BOOST_TYPEOF_EMULATION +# ifndef BOOST_TYPEOF_NATIVE +# define BOOST_TYPEOF_NATIVE +# endif +# define BOOST_TYPEOF_KEYWORD __typeof__ +# endif #else //unknown compiler # ifndef BOOST_TYPEOF_NATIVE # ifndef BOOST_TYPEOF_EMULATION @@ -206,7 +211,11 @@ #elif defined(BOOST_TYPEOF_NATIVE) # define BOOST_TYPEOF_TEXT "using native typeof" # include <boost/typeof/message.hpp> -# include <boost/typeof/native.hpp> +# ifdef BOOST_TYPEOF_DECLTYPE +# include <boost/typeof/decltype.hpp> +# else +# include <boost/typeof/native.hpp> +# endif #else # error typeof configuration error #endif |