From 65901249d5b97e1fb783db0d8265f616e08d3aca Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 24 May 2020 13:01:49 -0400 Subject: [PATCH] Workarounds for MSVC 2013 expression detection --- include/boost/core/allocator_access.hpp | 156 +++++++++++++++++++++--- 1 file changed, 138 insertions(+), 18 deletions(-) diff --git a/include/boost/core/allocator_access.hpp b/include/boost/core/allocator_access.hpp index 973127b..2a5d3c3 100644 --- a/include/boost/core/allocator_access.hpp +++ b/include/boost/core/allocator_access.hpp @@ -21,7 +21,8 @@ Distributed under the Boost Software License, Version 1.0. #include #endif -#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) || \ + defined(BOOST_MSVC) && BOOST_MSVC == 1800 #define BOOST_CORE_ALLOCATOR_DETECTION #endif @@ -263,27 +264,54 @@ template T alloc_declval() BOOST_NOEXCEPT; #endif -template +#if defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_yes { + BOOST_STATIC_CONSTEXPR bool value = true; +}; + +struct alloc_no { + BOOST_STATIC_CONSTEXPR bool value = false; +}; +#endif + +template struct alloc_has_allocate { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) -template -struct alloc_has_allocate().allocate(alloc_declval::type>(), alloc_declval::type>()), void())> { +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) +template +struct alloc_has_allocate().allocate(alloc_declval(), + alloc_declval()), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_allocate { +private: + template + static auto call(int, U& a) -> + alloc_yes(), + alloc_declval()))>; + + template + static alloc_no call(long, U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ template inline typename detail::alloc_if::value && - detail::alloc_has_allocate::value, - typename allocator_pointer::type>::type + detail::alloc_has_allocate::type, + typename allocator_const_void_pointer::type>::value, + typename allocator_pointer::type>::type allocator_allocate(A& a, typename allocator_size_type::type n, typename allocator_const_void_pointer::type h) { @@ -292,8 +320,9 @@ allocator_allocate(A& a, typename allocator_size_type::type n, template inline typename detail::alloc_if::value || - !detail::alloc_has_allocate::value, - typename allocator_pointer::type>::type + !detail::alloc_has_allocate::type, + typename allocator_const_void_pointer::type>::value, + typename allocator_pointer::type>::type allocator_allocate(A& a, typename allocator_size_type::type n, typename allocator_const_void_pointer::type) { @@ -315,12 +344,27 @@ struct alloc_has_construct { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_construct().construct(alloc_declval()), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_construct { +private: + template + static auto call(int, U& a) -> + alloc_yes()))>; + + template + static alloc_no call(long, U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ @@ -350,13 +394,29 @@ struct alloc_has_construct_args { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_construct_args().construct(alloc_declval(), alloc_declval()...), void()), A, T, Args...> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_construct_args { +private: + template + static auto call(int, U& a) -> + alloc_yes(), + alloc_declval()...))>; + + template + static alloc_no call(long, U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ @@ -384,13 +444,29 @@ struct alloc_has_construct_arg { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_construct_arg().construct(alloc_declval(), alloc_declval()), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_construct_arg { +private: + template + static auto call(int, U& a) -> + alloc_yes(), + alloc_declval()))>; + + template + static alloc_no call(long, U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ @@ -453,12 +529,27 @@ struct alloc_has_destroy { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_destroy().destroy(alloc_declval()), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_destroy { +private: + template + static auto call(int, U& a) -> + alloc_yes()))>; + + template + static alloc_no call(long, U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ @@ -487,12 +578,26 @@ struct alloc_has_max_size { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_max_size().max_size(), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_max_size { +private: + template + static auto call(int, const U& a) -> alloc_yes; + + template + static alloc_no call(long, const U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */ @@ -523,13 +628,28 @@ struct alloc_has_soccc { BOOST_STATIC_CONSTEXPR bool value = false; }; -#if defined(BOOST_CORE_ALLOCATOR_DETECTION) +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) template struct alloc_has_soccc().select_on_container_copy_construction(), void())> { BOOST_STATIC_CONSTEXPR bool value = true; }; +#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800 +template +struct alloc_has_soccc { +private: + template + static auto call(int, const U& a) -> + alloc_yes; + + template + static alloc_no call(long, const U&); + +public: + BOOST_STATIC_CONSTEXPR bool value = decltype(call(0, + alloc_declval()))::value; +}; #endif } /* detail */