diff --git a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp --- a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -79,7 +79,7 @@ typedef std::map, test_allocator > > Map; { LIBCPP_ASSERT(alloc_stats.alloc_count == 0); - Map s ({{1, 0}, {2, 0}, {3, 0}}, std::less(), test_allocator >(&alloc_stats)); + Map s({{1, 0}, {2, 0}, {3, 0}}, std::less(), test_allocator >(&alloc_stats)); LIBCPP_ASSERT(alloc_stats.alloc_count == 3); s = {{4, 0}, {4, 0}, {4, 0}, {4, 0}}; LIBCPP_ASSERT(alloc_stats.alloc_count == 1); diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h --- a/libcxx/test/support/test_allocator.h +++ b/libcxx/test/support/test_allocator.h @@ -51,9 +51,8 @@ } }; -const int destructed_value = -1; -const int default_value = 0; -const int moved_value = INT_MAX; +TEST_CONSTEXPR const int destructed_value = -1; +TEST_CONSTEXPR const int moved_value = INT_MAX; template class test_allocator { @@ -87,8 +86,9 @@ TEST_CONSTEXPR explicit test_allocator(int data) TEST_NOEXCEPT : data_(data) {} - TEST_CONSTEXPR_CXX14 explicit test_allocator(int data, test_allocator_statistics* stats) TEST_NOEXCEPT : data_(data), - stats_(stats) { + TEST_CONSTEXPR_CXX14 explicit test_allocator(int data, test_allocator_statistics* stats) TEST_NOEXCEPT + : data_(data), + stats_(stats) { if (stats != nullptr) ++stats_->count; } @@ -103,9 +103,9 @@ ++stats_->count; } - TEST_CONSTEXPR_CXX14 explicit test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), - id_(a.id_), - stats_(a.stats_) { + TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), + id_(a.id_), + stats_(a.stats_) { assert(a.data_ != destructed_value && a.id_ != destructed_value && "copying from destroyed allocator"); if (stats_ != nullptr) { ++stats_->count; @@ -136,8 +136,8 @@ } TEST_CONSTEXPR_CXX20 ~test_allocator() TEST_NOEXCEPT { - assert(data_ >= 0); - assert(id_ >= 0); + assert(data_ != destructed_value); + assert(id_ != destructed_value); if (stats_ != nullptr) --stats_->count; data_ = destructed_value; @@ -148,7 +148,7 @@ TEST_CONSTEXPR const_pointer address(const_reference x) const { return &x; } TEST_CONSTEXPR_CXX14 pointer allocate(size_type n, const void* = 0) { - assert(data_ >= 0); + assert(data_ != destructed_value); if (stats_ != nullptr) { if (stats_->time_to_throw >= stats_->throw_after) TEST_THROW(std::bad_alloc()); @@ -159,7 +159,7 @@ } TEST_CONSTEXPR_CXX14 void deallocate(pointer p, size_type) { - assert(data_ >= 0); + assert(data_ != destructed_value); if (stats_ != nullptr) --stats_->alloc_count; ::operator delete((void*)p); @@ -226,17 +226,17 @@ } ~non_default_test_allocator() TEST_NOEXCEPT { - assert(data_ >= 0); + assert(data_ != destructed_value); if (stats_ != nullptr) --stats_->count; - data_ = -1; + data_ = destructed_value; } pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pointer allocate(size_type n, const void* = 0) { - assert(data_ >= 0); + assert(data_ != destructed_value); if (stats_ != nullptr) { if (stats_->time_to_throw >= stats_->throw_after) TEST_THROW(std::bad_alloc()); @@ -246,7 +246,7 @@ return (pointer)::operator new(n * sizeof(T)); } void deallocate(pointer p, size_type) { - assert(data_ >= 0); + assert(data_ != destructed_value); if (stats_ != nullptr) --stats_->alloc_count; ::operator delete((void*)p); @@ -319,8 +319,8 @@ stats_(a.stats_) {} ~test_allocator() TEST_NOEXCEPT { - data_ = -1; - id_ = -1; + data_ = destructed_value; + id_ = destructed_value; } int get_id() const { return id_; }