Don't define StdAllocator<void> from C++17.

This commit is contained in:
ylavic 2021-03-30 13:47:04 +02:00
parent e336667b4a
commit 6bed9b266f
2 changed files with 6 additions and 0 deletions

View File

@ -581,6 +581,7 @@ private:
BaseAllocator baseAllocator_; BaseAllocator baseAllocator_;
}; };
#if !RAPIDJSON_HAS_CXX17 // std::allocator<void> deprecated in C++17
template <typename BaseAllocator> template <typename BaseAllocator>
class StdAllocator<void, BaseAllocator> : class StdAllocator<void, BaseAllocator> :
public std::allocator<void> public std::allocator<void>
@ -628,6 +629,7 @@ private:
BaseAllocator baseAllocator_; BaseAllocator baseAllocator_;
}; };
#endif
#ifdef __GNUC__ #ifdef __GNUC__
RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_POP

View File

@ -83,8 +83,12 @@ private:
template <typename Allocator> template <typename Allocator>
void TestStdAllocator(const Allocator& a) { void TestStdAllocator(const Allocator& a) {
#if RAPIDJSON_HAS_CXX17
typedef StdAllocator<bool, Allocator> BoolAllocator;
#else
typedef StdAllocator<void, Allocator> VoidAllocator; typedef StdAllocator<void, Allocator> VoidAllocator;
typedef typename VoidAllocator::template rebind<bool>::other BoolAllocator; typedef typename VoidAllocator::template rebind<bool>::other BoolAllocator;
#endif
BoolAllocator ba(a), ba2(a); BoolAllocator ba(a), ba2(a);
EXPECT_TRUE(ba == ba2); EXPECT_TRUE(ba == ba2);
EXPECT_FALSE(ba!= ba2); EXPECT_FALSE(ba!= ba2);