From 347bd3e7566434e5f11a693d973e74bdcb48b87f Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sun, 5 May 2019 09:21:25 +0700 Subject: [PATCH] fix gcc 4.9 unit test compilation --- flat_map_tests.cpp | 21 +++++++++++++++++++++ flat_set_tests.cpp | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/flat_map_tests.cpp b/flat_map_tests.cpp index eb7bb54..9424e42 100644 --- a/flat_map_tests.cpp +++ b/flat_map_tests.cpp @@ -17,8 +17,20 @@ namespace template < typename T > class dummy_allocator { public: + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; using value_type = T; + using propagate_on_container_move_assignment = std::true_type; + using is_always_equal = std::true_type; + + template < typename U > + struct rebind { using other = dummy_allocator; }; + dummy_allocator() = default; dummy_allocator(int i) : i(i) {} @@ -36,6 +48,15 @@ namespace std::free(p); } + template < typename U, typename... Args > + void construct(U* p, Args&&... args) { + ::new((void*)p) U(std::forward(args)...); + } + + void destroy(pointer p) { + p->~T(); + } + int i = 0; }; diff --git a/flat_set_tests.cpp b/flat_set_tests.cpp index 5c5332e..54e2f2e 100644 --- a/flat_set_tests.cpp +++ b/flat_set_tests.cpp @@ -17,8 +17,20 @@ namespace template < typename T > class dummy_allocator { public: + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; using value_type = T; + using propagate_on_container_move_assignment = std::true_type; + using is_always_equal = std::true_type; + + template < typename U > + struct rebind { using other = dummy_allocator; }; + dummy_allocator() = default; dummy_allocator(int i) : i(i) {} @@ -36,6 +48,15 @@ namespace std::free(p); } + template < typename U, typename... Args > + void construct(U* p, Args&&... args) { + ::new((void*)p) U(std::forward(args)...); + } + + void destroy(pointer p) { + p->~T(); + } + int i = 0; };