Skip to content

Commit

Permalink
Don't define StdAllocator<void> from C++17.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylavic committed Mar 30, 2021
1 parent e336667 commit 6bed9b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/rapidjson/allocators.h
Expand Up @@ -581,6 +581,7 @@ class StdAllocator :
BaseAllocator baseAllocator_;
};

#if !RAPIDJSON_HAS_CXX17 // std::allocator<void> deprecated in C++17
template <typename BaseAllocator>
class StdAllocator<void, BaseAllocator> :
public std::allocator<void>
Expand Down Expand Up @@ -628,6 +629,7 @@ class StdAllocator<void, BaseAllocator> :

BaseAllocator baseAllocator_;
};
#endif

#ifdef __GNUC__
RAPIDJSON_DIAG_POP
Expand Down
4 changes: 4 additions & 0 deletions test/unittest/allocatorstest.cpp
Expand Up @@ -83,8 +83,12 @@ struct TestStdAllocatorData {

template <typename Allocator>
void TestStdAllocator(const Allocator& a) {
#if RAPIDJSON_HAS_CXX17
typedef StdAllocator<bool, Allocator> BoolAllocator;
#else
typedef StdAllocator<void, Allocator> VoidAllocator;
typedef typename VoidAllocator::template rebind<bool>::other BoolAllocator;
#endif
BoolAllocator ba(a), ba2(a);
EXPECT_TRUE(ba == ba2);
EXPECT_FALSE(ba!= ba2);
Expand Down

0 comments on commit 6bed9b2

Please sign in to comment.