Skip to content

Commit 6bed9b2

Browse files
committed
Don't define StdAllocator<void> from C++17.
1 parent e336667 commit 6bed9b2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/rapidjson/allocators.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ class StdAllocator :
581581
BaseAllocator baseAllocator_;
582582
};
583583

584+
#if !RAPIDJSON_HAS_CXX17 // std::allocator<void> deprecated in C++17
584585
template <typename BaseAllocator>
585586
class StdAllocator<void, BaseAllocator> :
586587
public std::allocator<void>
@@ -628,6 +629,7 @@ class StdAllocator<void, BaseAllocator> :
628629

629630
BaseAllocator baseAllocator_;
630631
};
632+
#endif
631633

632634
#ifdef __GNUC__
633635
RAPIDJSON_DIAG_POP

test/unittest/allocatorstest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ struct TestStdAllocatorData {
8383

8484
template <typename Allocator>
8585
void TestStdAllocator(const Allocator& a) {
86+
#if RAPIDJSON_HAS_CXX17
87+
typedef StdAllocator<bool, Allocator> BoolAllocator;
88+
#else
8689
typedef StdAllocator<void, Allocator> VoidAllocator;
8790
typedef typename VoidAllocator::template rebind<bool>::other BoolAllocator;
91+
#endif
8892
BoolAllocator ba(a), ba2(a);
8993
EXPECT_TRUE(ba == ba2);
9094
EXPECT_FALSE(ba!= ba2);

0 commit comments

Comments
 (0)