Skip to content

Commit 47943d9

Browse files
min_allocator to main
1 parent adc5f50 commit 47943d9

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

libcxx/test/support/min_allocator.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class no_default_allocator {
4747
no_default_allocator();
4848
#endif
4949
struct construct_tag {};
50-
explicit no_default_allocator(construct_tag) {}
50+
TEST_CONSTEXPR_CXX20 explicit no_default_allocator(construct_tag) {}
5151

5252
public:
53-
static no_default_allocator create() {
53+
TEST_CONSTEXPR_CXX20 static no_default_allocator create() {
5454
construct_tag tag;
5555
return no_default_allocator(tag);
5656
}
@@ -59,14 +59,14 @@ class no_default_allocator {
5959
typedef T value_type;
6060

6161
template <class U>
62-
no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
62+
TEST_CONSTEXPR_CXX20 no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
6363

64-
T* allocate(std::size_t n) { return static_cast<T*>(::operator new(n * sizeof(T))); }
64+
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return static_cast<T*>(std::allocator<T>().allocate(n)); }
6565

66-
void deallocate(T* p, std::size_t) { return ::operator delete(static_cast<void*>(p)); }
66+
TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
6767

68-
friend bool operator==(no_default_allocator, no_default_allocator) { return true; }
69-
friend bool operator!=(no_default_allocator x, no_default_allocator y) { return !(x == y); }
68+
friend TEST_CONSTEXPR bool operator==(no_default_allocator, no_default_allocator) { return true; }
69+
friend TEST_CONSTEXPR bool operator!=(no_default_allocator x, no_default_allocator y) { return !(x == y); }
7070
};
7171

7272
struct malloc_allocator_base {
@@ -219,10 +219,7 @@ class min_pointer {
219219
public:
220220
min_pointer() TEST_NOEXCEPT = default;
221221
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
222-
// TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
223-
224-
// TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_((p.ptr_)) {}
225-
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_((p)) {}
222+
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
226223

227224
TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
228225

@@ -388,17 +385,15 @@ template <class T>
388385
class min_allocator {
389386
public:
390387
typedef T value_type;
391-
// typedef min_pointer<T> pointer;
392-
typedef T* pointer;
388+
typedef min_pointer<T> pointer;
393389

394390
min_allocator() = default;
395391
template <class U>
396392
TEST_CONSTEXPR_CXX20 min_allocator(min_allocator<U>) {}
397393

398394
TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator<T>().allocate(n)); }
399395

400-
// TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
401-
TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
396+
TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
402397

403398
TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) { return true; }
404399
TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) { return !(x == y); }

0 commit comments

Comments
 (0)