diff options
author | Yi Kong <yikong@google.com> | 2019-02-27 14:18:29 -0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2019-02-27 14:18:29 -0800 |
commit | 68d17cf1f10774944e53f53e015322253c0b4683 (patch) | |
tree | 3256f04ea3afe1ecd8cea84aba1ca8173ac8ec8a /test/support/min_allocator.h | |
parent | b72a4f7643b7139d62491d5aa45f2dc362d6fb7b (diff) | |
parent | 712d476de34e15f9fec9841c39b02b2993ff28ae (diff) | |
download | libcxx-master.tar.gz |
Merge 712d476de for LLVM update to 353983HEADmastermainllvm-r353983
Change-Id: I6635ce126bb89a38fab94e3e332d89ae703cd665
Diffstat (limited to 'test/support/min_allocator.h')
-rw-r--r-- | test/support/min_allocator.h | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/test/support/min_allocator.h b/test/support/min_allocator.h index a3af9e1db..100e6d14a 100644 --- a/test/support/min_allocator.h +++ b/test/support/min_allocator.h @@ -1,9 +1,8 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include <cstdlib> #include <cstddef> #include <cassert> +#include <climits> #include "test_macros.h" @@ -131,6 +131,59 @@ public: friend bool operator!=(malloc_allocator x, malloc_allocator y) {return !(x == y);} }; +template <class T> +struct cpp03_allocator : bare_allocator<T> +{ + typedef T value_type; + typedef value_type* pointer; + + static bool construct_called; + + // Returned value is not used but it's not prohibited. + pointer construct(pointer p, const value_type& val) + { + ::new(p) value_type(val); + construct_called = true; + return p; + } + + std::size_t max_size() const + { + return UINT_MAX / sizeof(T); + } +}; +template <class T> bool cpp03_allocator<T>::construct_called = false; + +template <class T> +struct cpp03_overload_allocator : bare_allocator<T> +{ + typedef T value_type; + typedef value_type* pointer; + + static bool construct_called; + + void construct(pointer p, const value_type& val) + { + construct(p, val, std::is_class<T>()); + } + void construct(pointer p, const value_type& val, std::true_type) + { + ::new(p) value_type(val); + construct_called = true; + } + void construct(pointer p, const value_type& val, std::false_type) + { + ::new(p) value_type(val); + construct_called = true; + } + + std::size_t max_size() const + { + return UINT_MAX / sizeof(T); + } +}; +template <class T> bool cpp03_overload_allocator<T>::construct_called = false; + #if TEST_STD_VER >= 11 |