1818
1919#include " test_macros.h"
2020
21- static std::ptrdiff_t allocated_;
21+ static std::size_t allocated_;
22+ static std::size_t deallocated_;
2223
2324template <class T , class Sz >
2425struct test_alloc {
@@ -41,12 +42,12 @@ struct test_alloc {
4142 TEST_CONSTEXPR test_alloc (const test_alloc<U, Sz>&) TEST_NOEXCEPT {}
4243
4344 pointer allocate (size_type n, const void * = nullptr ) {
44- allocated_ += static_cast <std::ptrdiff_t >(n);
45+ allocated_ += static_cast <std::size_t >(n);
4546 return std::allocator<value_type>().allocate (static_cast <std::size_t >(n));
4647 }
4748
4849 void deallocate (pointer p, size_type s) {
49- allocated_ - = static_cast <std::ptrdiff_t >(s);
50+ deallocated_ + = static_cast <std::size_t >(s);
5051 std::allocator<value_type>().deallocate (p, static_cast <std::size_t >(s));
5152 }
5253
@@ -65,13 +66,11 @@ struct test_alloc {
6566
6667template <class Sz >
6768void test () {
68- using Str = std::basic_string<char , std::char_traits<char >, test_alloc<char , Sz> >;
6969 for (int i = 1 ; i < 1000 ; ++i) {
7070 {
71- Str s (i, ' t' );
72- (void )s;
71+ TEST_MAYBE_UNUSED std::basic_string<char , std::char_traits<char >, test_alloc<char , Sz> > s (i, ' t' );
7372 }
74- assert (allocated_ == 0 );
73+ assert (allocated_ == deallocated_ );
7574 }
7675}
7776
0 commit comments