From 12e1fe615a34c9a5e6ebe3ddf629c6491a50aa9d Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Fri, 14 Apr 2017 15:44:31 +0200 Subject: [PATCH] enable use of msvc compiler option /permissive- The compiler hack used to emulate __typeof__ on msvc no longer works when compiler option /permissive- is engaged. Rather than preying on a compiler bug take advantage of modern c++ instead. Signed-off-by: Daniela Engert --- include/boost/typeof/decltype.hpp | 34 +++++++++++++++++++++++++++++++ include/boost/typeof/typeof.hpp | 16 +++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 include/boost/typeof/decltype.hpp diff --git a/include/boost/typeof/decltype.hpp b/include/boost/typeof/decltype.hpp new file mode 100644 index 0000000..a375409 --- /dev/null +++ b/include/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 +#include + +namespace boost { namespace type_of { + template + using remove_cv_ref_t = typename remove_cv::type>::type; +}} + +#define BOOST_TYPEOF(expr) boost::type_of::remove_cv_ref_t +#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/include/boost/typeof/typeof.hpp b/include/boost/typeof/typeof.hpp index c52b480..1efa3dc 100644 --- a/include/boost/typeof/typeof.hpp +++ b/include/boost/typeof/typeof.hpp @@ -13,7 +13,15 @@ # error both typeof emulation and native mode requested #endif -#if defined(__COMO__) +#include + +#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 @@ -203,7 +211,11 @@ #elif defined(BOOST_TYPEOF_NATIVE) # define BOOST_TYPEOF_TEXT "using native typeof" # include -# include +# ifdef BOOST_TYPEOF_DECLTYPE +# include +# else +# include +# endif #else # error typeof configuration error #endif