From 852c24483bf9ba4845fb6bc3b8fcfec77bf9be7a Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Fri, 25 Nov 2022 16:55:53 +0100 Subject: [PATCH] fix issue #145 --- include/foonathan/memory/allocator_storage.hpp | 8 ++++++++ include/foonathan/memory/config.hpp | 5 +++++ include/foonathan/memory/std_allocator.hpp | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/include/foonathan/memory/allocator_storage.hpp b/include/foonathan/memory/allocator_storage.hpp index 6c22029..654acd4 100644 --- a/include/foonathan/memory/allocator_storage.hpp +++ b/include/foonathan/memory/allocator_storage.hpp @@ -126,7 +126,11 @@ namespace foonathan FOONATHAN_REQUIRES( (!std::is_base_of::type>::value))> allocator_storage(Alloc&& alloc, +#if FOONATHAN_SFINAE_WORKAROUND + FOONATHAN_SFINAE(new storage_policy(std::declval()))) +#else FOONATHAN_SFINAE(new storage_policy(detail::forward(alloc)))) +#endif : storage_policy(detail::forward(alloc)) { } @@ -137,7 +141,11 @@ namespace foonathan /// otherwise this constructor does not participate in overload resolution. template allocator_storage(const allocator_storage& other, +#if FOONATHAN_SFINAE_WORKAROUND + FOONATHAN_SFINAE(new storage_policy(std::declval&>().get_allocator()))) +#else FOONATHAN_SFINAE(new storage_policy(other.get_allocator()))) +#endif : storage_policy(other.get_allocator()) { } diff --git a/include/foonathan/memory/config.hpp b/include/foonathan/memory/config.hpp index 62229b6..77602f9 100644 --- a/include/foonathan/memory/config.hpp +++ b/include/foonathan/memory/config.hpp @@ -43,6 +43,11 @@ #endif #endif +// SFINAE workaround for MSVC 19.33 +#ifndef FOONATHAN_SFINAE_WORKAROUND +#define FOONATHAN_SFINAE_WORKAROUND 1 +#endif + // log prefix #define FOONATHAN_MEMORY_LOG_PREFIX "foonathan::memory" diff --git a/include/foonathan/memory/std_allocator.hpp b/include/foonathan/memory/std_allocator.hpp index 55a5ca6..4649e32 100644 --- a/include/foonathan/memory/std_allocator.hpp +++ b/include/foonathan/memory/std_allocator.hpp @@ -134,7 +134,11 @@ namespace foonathan // MSVC seems to ignore access rights in decltype SFINAE below // use this to prevent this constructor being chosen instead of move/copy for types inheriting from it FOONATHAN_REQUIRES((!std::is_base_of::value))> +#if FOONATHAN_SFINAE_WORKAROUND + std_allocator(RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(std::declval()))) noexcept +#else std_allocator(RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(alloc))) noexcept +#endif : alloc_reference(alloc) { } @@ -149,7 +153,11 @@ namespace foonathan // MSVC seems to ignore access rights in decltype SFINAE below // use this to prevent this constructor being chosen instead of move/copy for types inheriting from it FOONATHAN_REQUIRES((!std::is_base_of::value))> +#if FOONATHAN_SFINAE_WORKAROUND + std_allocator(const RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(std::declval()))) noexcept +#else std_allocator(const RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(alloc))) noexcept +#endif : alloc_reference(alloc) { }