[libc++] Make list constexpr as part of P3372R3 (#129799)

This patch makes `std::list` constexpr as part of P3372R3.

Fixes #128659.
This commit is contained in:
Peng Liu 2025-06-18 12:13:50 -04:00 committed by GitHub
parent a2cee05449
commit 13510c0736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
70 changed files with 1555 additions and 797 deletions

View File

@ -422,6 +422,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_forward_list`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_list`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_new`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_queue`` ``202502L``

File diff suppressed because it is too large Load Diff

View File

@ -71,6 +71,7 @@ __cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_forward_list 202502L <forward_list>
__cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
__cpp_lib_constexpr_list 202502L <list>
__cpp_lib_constexpr_memory 202202L <memory>
201811L // C++20
__cpp_lib_constexpr_new 202406L <new>
@ -545,6 +546,7 @@ __cpp_lib_void_t 201411L <type_traits>
# undef __cpp_lib_constexpr_algorithms
# define __cpp_lib_constexpr_algorithms 202306L
# define __cpp_lib_constexpr_forward_list 202502L
# define __cpp_lib_constexpr_list 202502L
# if !defined(_LIBCPP_ABI_VCRUNTIME)
# define __cpp_lib_constexpr_new 202406L
# endif

View File

@ -10,34 +10,34 @@
// template< class T, class Alloc >
// bool operator==( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator!=( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator<( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator<=( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator>( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator>=( const std::list<T,Alloc>& lhs,
// const std::list<T,Alloc>& rhs );
// const std::list<T,Alloc>& rhs ); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_comparisons.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
const std::list<int> l1, l2;
assert(testComparisons(l1, l2, true, false));
@ -113,5 +113,15 @@ int main(int, char**) {
const std::list<LessAndEqComp> l2(items2, items2 + 2);
assert(testComparisons(l1, l2, false, false));
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -11,7 +11,7 @@
// template <class T, class Allocator> constexpr
// synth-three-way-result<T>
// operator<=>(const list<T, Allocator>& x, const list<T, Allocator>& y);
// operator<=>(const list<T, Allocator>& x, const list<T, Allocator>& y); // constexpr since C++26
#include <list>
#include <cassert>
@ -20,6 +20,8 @@
int main(int, char**) {
assert(test_sequence_container_spaceship<std::list>());
// `std::list` is not constexpr, so no `static_assert` test here.
#if TEST_STD_VER >= 26
static_assert(test_sequence_container_spaceship<std::list>());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// class list
// allocator_type get_allocator() const
// allocator_type get_allocator() const // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::allocator<int> alloc;
const std::list<int> l(alloc);
@ -30,5 +30,14 @@ int main(int, char**) {
assert(l.get_allocator() == alloc);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -12,6 +12,7 @@
// type.
#include <list>
#include <cassert>
#include "test_macros.h"
@ -23,8 +24,18 @@ struct A {
std::list<A>::const_reverse_iterator crit;
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
A a;
(void)a;
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,12 +8,12 @@
// <list>
// iterator begin();
// iterator end();
// const_iterator begin() const;
// const_iterator end() const;
// const_iterator cbegin() const;
// const_iterator cend() const;
// iterator begin(); // constexpr since C++26
// iterator end(); // constexpr since C++26
// const_iterator begin() const; // constexpr since C++26
// const_iterator end() const; // constexpr since C++26
// const_iterator cbegin() const; // constexpr since C++26
// const_iterator cend() const; // constexpr since C++26
#include <list>
#include <cassert>
@ -27,7 +27,7 @@ struct A {
int second;
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int T;
typedef std::list<T> C;
@ -74,6 +74,8 @@ int main(int, char**) {
typedef std::list<T> C;
C::iterator i;
C::const_iterator j;
(void)i;
(void)j;
}
#if TEST_STD_VER >= 11
{
@ -122,6 +124,8 @@ int main(int, char**) {
typedef std::list<T, min_allocator<T>> C;
C::iterator i;
C::const_iterator j;
(void)i;
(void)j;
}
{
typedef A T;
@ -150,5 +154,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// class list
// bool empty() const noexcept;
// bool empty() const noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<int> C;
C c;
@ -42,5 +42,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// size_type max_size() const noexcept
// size_type max_size() const noexcept // constexpr since C++26
#include <cassert>
#include <limits>
@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef limited_allocator<int, 10> A;
typedef std::list<int, A> C;
@ -42,5 +42,14 @@ int main(int, char**) {
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,15 +8,16 @@
// <list>
// void resize(size_type sz);
// void resize(size_type sz); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_macros.h"
#include "DefaultOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(5, 2);
l.resize(2);
@ -33,17 +34,31 @@ int main(int, char**) {
assert(l.back() == 0);
}
#if TEST_STD_VER >= 11
{
std::list<DefaultOnly> l(10);
l.resize(5);
assert(l.size() == 5);
assert(std::distance(l.begin(), l.end()) == 5);
}
{
std::list<DefaultOnly> l(10);
l.resize(20);
assert(l.size() == 20);
assert(std::distance(l.begin(), l.end()) == 20);
if (!TEST_IS_CONSTANT_EVALUATED) {
{
std::list<DefaultOnly> l(10);
l.resize(5);
assert(l.size() == 5);
assert(std::distance(l.begin(), l.end()) == 5);
}
{
std::list<DefaultOnly> l(10);
l.resize(20);
assert(l.size() == 20);
assert(std::distance(l.begin(), l.end()) == 20);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
l.resize(5);
assert(l.size() == 5);
assert(std::distance(l.begin(), l.end()) == 5);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
l.resize(20);
assert(l.size() == 20);
assert(std::distance(l.begin(), l.end()) == 20);
}
}
{
std::list<int, min_allocator<int>> l(5, 2);
@ -60,18 +75,15 @@ int main(int, char**) {
assert(l.front() == 2);
assert(l.back() == 0);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
l.resize(5);
assert(l.size() == 5);
assert(std::distance(l.begin(), l.end()) == 5);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
l.resize(20);
assert(l.size() == 20);
assert(std::distance(l.begin(), l.end()) == 20);
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;

View File

@ -8,7 +8,7 @@
// <list>
// void resize(size_type sz, const value_type& x);
// void resize(size_type sz, const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<double> l(5, 2);
l.resize(2, 3.5);
@ -50,5 +50,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// class list
// size_type size() const noexcept;
// size_type size() const noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<int> C;
C c;
@ -58,5 +58,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// list& operator=(const list& c);
// list& operator=(const list& c); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@ -41,5 +41,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// void assign(initializer_list<value_type> il);
// void assign(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d;
d.assign({3, 4, 5, 6});
@ -40,5 +40,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// list& operator=(list&& c);
// list& operator=(list&& c); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -79,5 +79,14 @@ int main(int, char**) {
assert(it == l2.begin()); // Iterators remain valid
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// list(const list& c);
// list(const list& c); // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3, 2);
std::list<int> l2 = l;
@ -50,5 +50,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// list(const list& c, const allocator_type& a);
// list(const list& c, const allocator_type& a); // constexpr since C++26
#include <list>
#include <cassert>
@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@ -39,5 +39,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// explicit list(const Alloc& = Alloc());
// explicit list(const Alloc& = Alloc()); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l;
assert(l.size() == 0);
@ -65,5 +65,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// explicit list(const Alloc& = Alloc());
// explicit list(const Alloc& = Alloc()); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l;
assert(l.size() == 0);
@ -45,5 +45,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,14 +9,15 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
// list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23
// list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23; constexpr since C++26
#include <list>
#include <type_traits>
#include "../../from_range_sequence_containers.h"
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
for_all_iterators_and_allocators<int>([]<class Iter, class Sent, class Alloc>() {
test_sequence_container<std::list, int, Iter, Sent, Alloc>([](const auto&) {
// No additional validation to do.
@ -26,8 +27,19 @@ int main(int, char**) {
static_assert(test_constraints<std::list, int, double>());
test_exception_safety_throwing_copy<std::list>();
test_exception_safety_throwing_allocator<std::list, int>();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_exception_safety_throwing_copy<std::list>();
test_exception_safety_throwing_allocator<std::list, int>();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// list(initializer_list<value_type> il);
// list(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
@ -38,5 +38,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
// list(initializer_list<value_type> il, const Allocator& a = allocator_type()); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
assert(d.get_allocator() == test_allocator<int>(3));
@ -41,5 +41,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,10 +9,11 @@
// <list>
// template <class InputIterator>
// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
// list(InputIterator first, InputIterator last, const Allocator& = Allocator()); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
#include "test_allocator.h"
@ -22,7 +23,7 @@
# include "container_test_types.h"
#endif
void basic_test() {
TEST_CONSTEXPR_CXX26 void basic_test() {
{
int a[] = {0, 1, 2, 3};
std::list<int> l(
@ -81,7 +82,7 @@ void basic_test() {
#endif
}
void test_emplacable_concept() {
TEST_CONSTEXPR_CXX26 void test_emplacable_concept() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@ -126,7 +127,7 @@ void test_emplacable_concept() {
#endif
}
void test_emplacable_concept_with_alloc() {
TEST_CONSTEXPR_CXX26 void test_emplacable_concept_with_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@ -239,12 +240,24 @@ void test_ctor_under_alloc_with_alloc() {
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
basic_test();
test_emplacable_concept();
test_emplacable_concept_with_alloc();
test_ctor_under_alloc();
test_ctor_under_alloc_with_alloc();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_ctor_under_alloc();
test_ctor_under_alloc_with_alloc();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// list(list&& c);
// list(list&& c); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -63,5 +63,14 @@ int main(int, char**) {
assert(it == l2.begin()); // Iterators remain valid
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// list(list&& c, const allocator_type& a);
// list(list&& c, const allocator_type& a); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -69,5 +69,14 @@ int main(int, char**) {
assert(l2.get_allocator() == min_allocator<MoveOnly>());
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,14 +10,14 @@
// <list>
// list& operator=(initializer_list<value_type> il);
// list& operator=(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d;
d = {3, 4, 5, 6};
@ -39,5 +39,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,18 +8,19 @@
// <list>
// explicit list(size_type n);
// explicit list(size_type n); // constexpr since C++26
#include <list>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
#include "DefaultOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
template <class T, class Allocator>
void test3(unsigned n, Allocator const& alloc = Allocator()) {
TEST_CONSTEXPR_CXX26 void test1(unsigned n, Allocator const& alloc = Allocator()) {
#if TEST_STD_VER > 11
typedef std::list<T, Allocator> C;
{
@ -34,7 +35,7 @@ void test3(unsigned n, Allocator const& alloc = Allocator()) {
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3);
assert(l.size() == 3);
@ -70,15 +71,10 @@ int main(int, char**) {
assert(*i == 0);
++i;
assert(*i == 0);
test3<int, min_allocator<int>>(3);
test1<int, min_allocator<int>>(3);
}
#endif
#if TEST_STD_VER >= 11
{
std::list<DefaultOnly> l(3);
assert(l.size() == 3);
assert(std::distance(l.begin(), l.end()) == 3);
}
{
std::list<int, min_allocator<int>> l(3);
assert(l.size() == 3);
@ -90,12 +86,29 @@ int main(int, char**) {
++i;
assert(*i == 0);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
assert(l.size() == 3);
assert(std::distance(l.begin(), l.end()) == 3);
if (!TEST_IS_CONSTANT_EVALUATED) {
{
std::list<DefaultOnly> l(3);
assert(l.size() == 3);
assert(std::distance(l.begin(), l.end()) == 3);
}
{
std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
assert(l.size() == 3);
assert(std::distance(l.begin(), l.end()) == 3);
}
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// list(size_type n, const T& value, const Allocator& = Allocator());
// list(size_type n, const T& value, const Allocator& = Allocator()); // constexpr since C++26
#include <list>
#include <cassert>
@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3, 2);
assert(l.size() == 3);
@ -77,5 +77,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -11,7 +11,7 @@
// template <class T, class Allocator, class U>
// typename list<T, Allocator>::size_type
// erase(list<T, Allocator>& c, const U& value);
// erase(list<T, Allocator>& c, const U& value); // constexpr since C++26
#include <list>
#include <optional>
@ -21,14 +21,14 @@
#include "min_allocator.h"
template <class S, class U>
void test0(S s, U val, S expected, std::size_t expected_erased_count) {
TEST_CONSTEXPR_CXX26 void test0(S s, U val, S expected, std::size_t expected_erased_count) {
ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase(s, val)));
assert(expected_erased_count == std::erase(s, val));
assert(s == expected);
}
template <class S>
void test() {
TEST_CONSTEXPR_CXX26 void test1() {
test0(S(), 1, S(), 0);
test0(S({1}), 1, S(), 1);
@ -62,13 +62,22 @@ void test() {
test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0);
}
int main(int, char**) {
test<std::list<int>>();
test<std::list<int, min_allocator<int>>>();
test<std::list<int, test_allocator<int>>>();
TEST_CONSTEXPR_CXX26 bool test() {
test1<std::list<int>>();
test1<std::list<int, min_allocator<int>>>();
test1<std::list<int, test_allocator<int>>>();
test<std::list<long>>();
test<std::list<double>>();
test1<std::list<long>>();
test1<std::list<double>>();
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -11,7 +11,7 @@
// template <class T, class Allocator, class Predicate>
// typename list<T, Allocator>::size_type
// erase_if(list<T, Allocator>& c, Predicate pred);
// erase_if(list<T, Allocator>& c, Predicate pred); // constexpr since C++26
#include <list>
@ -20,14 +20,14 @@
#include "min_allocator.h"
template <class S, class Pred>
void test0(S s, Pred p, S expected, std::size_t expected_erased_count) {
TEST_CONSTEXPR_CXX26 void test0(S s, Pred p, S expected, std::size_t expected_erased_count) {
ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase_if(s, p)));
assert(expected_erased_count == std::erase_if(s, p));
assert(s == expected);
}
template <typename S>
void test() {
TEST_CONSTEXPR_CXX26 void test1() {
auto is1 = [](auto v) { return v == 1; };
auto is2 = [](auto v) { return v == 2; };
auto is3 = [](auto v) { return v == 3; };
@ -64,13 +64,22 @@ void test() {
test0(S({1, 2, 3}), False, S({1, 2, 3}), 0);
}
int main(int, char**) {
test<std::list<int>>();
test<std::list<int, min_allocator<int>>>();
test<std::list<int, test_allocator<int>>>();
TEST_CONSTEXPR_CXX26 bool test() {
test1<std::list<int>>();
test1<std::list<int, min_allocator<int>>>();
test1<std::list<int, test_allocator<int>>>();
test<std::list<long>>();
test<std::list<double>>();
test1<std::list<long>>();
test1<std::list<double>>();
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
// constexpr void append_range(R&& rg); // C++23
// constexpr void append_range(R&& rg); // C++23; constexpr since C++26
#include <list>
#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - appending move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_append_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_append_range_move_only<std::list>();
test_append_range_exception_safety_throwing_copy<std::list>();
test_append_range_exception_safety_throwing_allocator<std::list, int>();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_append_range_exception_safety_throwing_copy<std::list>();
test_append_range_exception_safety_throwing_allocator<std::list, int>();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
// constexpr void assign_range(R&& rg); // C++23
// constexpr void assign_range(R&& rg); // C++23; constexpr since C++26
#include <list>
#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - assigning move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_assign_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_assign_range_move_only<std::list>();
test_assign_range_exception_safety_throwing_copy<std::list>();
test_assign_range_exception_safety_throwing_allocator<std::list, int>();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_assign_range_exception_safety_throwing_copy<std::list>();
test_assign_range_exception_safety_throwing_allocator<std::list, int>();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void clear() noexcept;
// void clear() noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// template <class... Args> void emplace(const_iterator p, Args&&... args);
// template <class... Args> void emplace(const_iterator p, Args&&... args); // constexpr since C++26
#include <list>
#include <cassert>
@ -26,13 +26,13 @@ class A {
A& operator=(const A&);
public:
A(int i, double d) : i_(i), d_(d) {}
TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
int geti() const { return i_; }
double getd() const { return d_; }
TEST_CONSTEXPR int geti() const { return i_; }
TEST_CONSTEXPR double getd() const { return d_; }
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
c.emplace(c.cbegin(), 2, 3.5);
@ -60,5 +60,14 @@ int main(int, char**) {
assert(c.back().getd() == 4.5);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// template <class... Args> reference emplace_back(Args&&... args);
// template <class... Args> reference emplace_back(Args&&... args); // constexpr since C++26
// return type is 'reference' in C++17; 'void' before
#include <list>
@ -27,13 +27,13 @@ class A {
A& operator=(const A&);
public:
A(int i, double d) : i_(i), d_(d) {}
TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
int geti() const { return i_; }
double getd() const { return d_; }
TEST_CONSTEXPR int geti() const { return i_; }
TEST_CONSTEXPR double getd() const { return d_; }
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
#if TEST_STD_VER > 14
@ -83,5 +83,14 @@ int main(int, char**) {
assert(c.back().getd() == 4.5);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// template <class... Args> reference emplace_front(Args&&... args);
// template <class... Args> reference emplace_front(Args&&... args); // constexpr since C++26
// return type is 'reference' in C++17; 'void' before
#include <list>
@ -27,13 +27,13 @@ class A {
A& operator=(const A&);
public:
A(int i, double d) : i_(i), d_(d) {}
TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
int geti() const { return i_; }
double getd() const { return d_; }
TEST_CONSTEXPR int geti() const { return i_; }
TEST_CONSTEXPR double getd() const { return d_; }
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
#if TEST_STD_VER > 14
@ -84,5 +84,14 @@ int main(int, char**) {
assert(c.back().getd() == 3.5);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// iterator erase(const_iterator position);
// iterator erase(const_iterator position); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1 + 3);
@ -62,5 +62,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// iterator erase(const_iterator first, const_iterator last);
// iterator erase(const_iterator first, const_iterator last); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
{
std::list<int> l1(a1, a1 + 3);
@ -81,5 +81,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// iterator insert(const_iterator p, initializer_list<value_type> il);
// iterator insert(const_iterator p, initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d(10, 1);
std::list<int>::iterator i = d.insert(std::next(d.cbegin(), 2), {3, 4, 5, 6});
@ -62,5 +62,14 @@ int main(int, char**) {
assert(*i++ == 1);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// template <InputIterator Iter>
// iterator insert(const_iterator position, Iter first, Iter last);
// iterator insert(const_iterator position, Iter first, Iter last); // constexpr since C++26
#include <list>
#include <cstdlib>
@ -21,7 +21,7 @@
#include "count_new.h"
template <class List>
void test() {
TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
List l1;
typename List::iterator i = l1.insert(l1.begin(), a1, a1 + 3);
@ -53,36 +53,47 @@ void test() {
assert(*i == 3);
#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
globalMemCounter.throw_after = 2;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, a2, a2 + 3);
assert(false);
} catch (...) {
if (!TEST_IS_CONSTANT_EVALUATED) {
globalMemCounter.throw_after = 2;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, a2, a2 + 3);
assert(false);
} catch (...) {
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1.size() == 6);
assert(std::distance(l1.begin(), l1.end()) == 6);
i = l1.begin();
assert(*i == 1);
++i;
assert(*i == 2);
++i;
assert(*i == 4);
++i;
assert(*i == 5);
++i;
assert(*i == 6);
++i;
assert(*i == 3);
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1.size() == 6);
assert(std::distance(l1.begin(), l1.end()) == 6);
i = l1.begin();
assert(*i == 1);
++i;
assert(*i == 2);
++i;
assert(*i == 4);
++i;
assert(*i == 5);
++i;
assert(*i == 6);
++i;
assert(*i == 3);
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// iterator insert(const_iterator position, value_type&& x);
// iterator insert(const_iterator position, value_type&& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.insert(l1.cend(), MoveOnly(1));
@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(1));
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// iterator insert(const_iterator position, size_type n, const value_type& x);
// iterator insert(const_iterator position, size_type n, const value_type& x); // constexpr since C++26
// UNSUPPORTED: sanitizer-new-delete
@ -21,7 +21,7 @@
#include "test_macros.h"
template <class List>
void test() {
TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
List l1(a1, a1 + 3);
@ -29,23 +29,34 @@ void test() {
assert(i == std::next(l1.begin()));
assert(l1 == List(a2, a2 + 8));
#ifndef TEST_HAS_NO_EXCEPTIONS
globalMemCounter.throw_after = 4;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, 5, 5);
assert(false);
} catch (...) {
if (!TEST_IS_CONSTANT_EVALUATED) {
globalMemCounter.throw_after = 4;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, 5, 5);
assert(false);
} catch (...) {
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1 == List(a2, a2 + 8));
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1 == List(a2, a2 + 8));
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// iterator insert(const_iterator position, const value_type& x);
// iterator insert(const_iterator position, const value_type& x); // constexpr since C++26
#include <list>
#include <cstdlib>
@ -19,7 +19,7 @@
#include "count_new.h"
template <class List>
void test() {
TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 2, 3};
List l1(a1, a1 + 3);
@ -30,23 +30,34 @@ void test() {
assert(l1 == List(a2, a2 + 4));
#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
globalMemCounter.throw_after = 0;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, 5);
assert(false);
} catch (...) {
if (!TEST_IS_CONSTANT_EVALUATED) {
globalMemCounter.throw_after = 0;
int save_count = globalMemCounter.outstanding_new;
try {
i = l1.insert(i, 5);
assert(false);
} catch (...) {
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1 == List(a2, a2 + 4));
}
assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1 == List(a2, a2 + 4));
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -6,12 +6,16 @@
//
//===----------------------------------------------------------------------===//
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=20000000
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=80000000
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
// constexpr iterator insert_range(const_iterator position, R&& rg); // C++23
// constexpr iterator insert_range(const_iterator position, R&& rg); // C++23; constexpr since C++26
#include <list>
#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@ -21,7 +25,7 @@
// {empty/one-element/full} container at the {beginning/middle/end});
// - inserting move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_insert_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@ -31,8 +35,19 @@ int main(int, char**) {
});
test_sequence_insert_range_move_only<std::list>();
test_insert_range_exception_safety_throwing_copy<std::list>();
test_insert_range_exception_safety_throwing_allocator<std::list, int>();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_insert_range_exception_safety_throwing_copy<std::list>();
test_insert_range_exception_safety_throwing_allocator<std::list, int>();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void pop_back();
// void pop_back(); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@ -40,5 +40,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void pop_front();
// void pop_front(); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@ -40,5 +40,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
// constexpr void prepend_range(R&& rg); // C++23
// constexpr void prepend_range(R&& rg); // C++23; constexpr since C++26
#include <list>
#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - prepending move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_prepend_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_prepend_range_move_only<std::list>();
test_prepend_range_exception_safety_throwing_copy<std::list>();
test_prepend_range_exception_safety_throwing_allocator<std::list, int>();
if (!TEST_IS_CONSTANT_EVALUATED) {
test_prepend_range_exception_safety_throwing_copy<std::list>();
test_prepend_range_exception_safety_throwing_allocator<std::list, int>();
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void push_back(const value_type& x);
// void push_back(const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> c;
for (int i = 0; i < 5; ++i)
@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// void push_back(value_type&& x);
// void push_back(value_type&& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.push_back(MoveOnly(1));
@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(2));
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void push_front(const value_type& x);
// void push_front(const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> c;
for (int i = 0; i < 5; ++i)
@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -10,7 +10,7 @@
// <list>
// void push_front(value_type&& x);
// void push_front(value_type&& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.push_front(MoveOnly(1));
@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(1));
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void merge(list& x);
// void merge(list& x); // constexpr since C++26
// If (addressof(x) == this) does nothing; otherwise ...
#include <list>
@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@ -49,5 +49,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// template <class Compare> void merge(list& x, Compare comp);
// template <class Compare> void merge(list& x, Compare comp); // constexpr since C++26
// If (addressof(x) == this) does nothing; otherwise ...
#include <list>
@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {10, 9, 7, 3, 1};
int a2[] = {11, 8, 6, 5, 4, 2, 0};
@ -49,5 +49,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// void remove(const value_type& value); // pre-c++20
// size_type remove(const value_type& value); // c++20 and later
// size_type remove(const value_type& value); // c++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@ -18,22 +18,22 @@
#include "min_allocator.h"
struct S {
S(int i) : i_(new int(i)) {}
S(const S& rhs) : i_(new int(*rhs.i_)) {}
S& operator=(const S& rhs) {
TEST_CONSTEXPR_CXX20 S(int i) : i_(new int(i)) {}
TEST_CONSTEXPR_CXX20 S(const S& rhs) : i_(new int(*rhs.i_)) {}
TEST_CONSTEXPR_CXX14 S& operator=(const S& rhs) {
*i_ = *rhs.i_;
return *this;
}
~S() {
TEST_CONSTEXPR_CXX20 ~S() {
delete i_;
i_ = NULL;
}
bool operator==(const S& rhs) const { return *i_ == *rhs.i_; }
int get() const { return *i_; }
TEST_CONSTEXPR bool operator==(const S& rhs) const { return *i_ == *rhs.i_; }
TEST_CONSTEXPR int get() const { return *i_; }
int* i_;
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 2, 4};
@ -101,5 +101,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// template <class Pred> void remove_if(Pred pred); // before C++20
// template <class Pred> size_type remove_if(Pred pred); // c++20 and later
// template <class Pred> size_type remove_if(Pred pred); // c++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@ -19,22 +19,22 @@
#include "min_allocator.h"
#include "counting_predicates.h"
bool even(int i) { return i % 2 == 0; }
TEST_CONSTEXPR bool even(int i) { return i % 2 == 0; }
bool g(int i) { return i < 3; }
TEST_CONSTEXPR bool g(int i) { return i < 3; }
struct PredLWG526 {
PredLWG526(int i) : i_(i) {}
~PredLWG526() { i_ = -32767; }
bool operator()(const PredLWG526& p) const { return p.i_ == i_; }
TEST_CONSTEXPR_CXX20 PredLWG526(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 ~PredLWG526() { i_ = -32767; }
TEST_CONSTEXPR bool operator()(const PredLWG526& p) const { return p.i_ == i_; }
bool operator==(int i) const { return i == i_; }
TEST_CONSTEXPR bool operator==(int i) const { return i == i_; }
int i_;
};
typedef unary_counting_predicate<bool (*)(int), int> Predicate;
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3, 4};
int a2[] = {3, 4};
@ -92,5 +92,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void reverse();
// void reverse(); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void sort();
// void sort(); // constexpr since C++26
#include <algorithm>
#include <list>
@ -58,7 +58,7 @@ void test_stable(int N) {
}
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
@ -76,8 +76,19 @@ int main(int, char**) {
}
#endif
for (int i = 0; i < 40; ++i)
test_stable(i);
if (!TEST_IS_CONSTANT_EVALUATED) {
for (int i = 0; i < 40; ++i)
test_stable(i);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// template <class Compare> sort(Compare comp);
// template <class Compare> sort(Compare comp); // constexpr since C++26
#include <list>
#include <functional>
@ -76,7 +76,7 @@ void test_stable(int N) {
}
}
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
@ -85,37 +85,48 @@ int main(int, char**) {
assert(c1 == std::list<int>(a2, a2 + sizeof(a2) / sizeof(a2[0])));
}
if (!TEST_IS_CONSTANT_EVALUATED) {
// Test with throwing comparison; make sure that nothing is lost.
// This is (sort of) LWG #2824
#ifndef TEST_HAS_NO_EXCEPTIONS
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
const int sz = sizeof(a1) / sizeof(a1[0]);
for (int i = 0; i < 10; ++i) {
std::list<int> c1(a1, a1 + sz);
try {
throwingLess<int> comp(i);
c1.sort(std::cref(comp));
} catch (int) {
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
const int sz = sizeof(a1) / sizeof(a1[0]);
for (int i = 0; i < 10; ++i) {
std::list<int> c1(a1, a1 + sz);
try {
throwingLess<int> comp(i);
c1.sort(std::cref(comp));
} catch (int) {
}
assert((c1.size() == sz));
assert((std::is_permutation(c1.begin(), c1.end(), a1)));
}
assert((c1.size() == sz));
assert((std::is_permutation(c1.begin(), c1.end(), a1)));
}
}
#endif
#if TEST_STD_VER >= 11
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
std::list<int, min_allocator<int>> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));
c1.sort(std::greater<int>());
assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + sizeof(a2) / sizeof(a2[0]))));
}
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
std::list<int, min_allocator<int>> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));
c1.sort(std::greater<int>());
assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + sizeof(a2) / sizeof(a2[0]))));
}
#endif
for (int i = 0; i < 40; ++i)
test_stable(i);
for (int i = 0; i < 40; ++i)
test_stable(i);
}
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void splice(const_iterator position, list& x);
// void splice(const_iterator position, list& x); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@ -780,5 +780,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
// void splice(const_iterator position, list<T,Allocator>& x, iterator i); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@ -334,5 +334,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -8,7 +8,7 @@
// <list>
// void splice(const_iterator position, list& x, iterator first, iterator last);
// void splice(const_iterator position, list& x, iterator first, iterator last); // constexpr since C++26
#include <list>
#include <cassert>
@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@ -214,5 +214,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// void unique(); // before C++20
// size_type unique(); // C++20 and later
// size_type unique(); // C++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
@ -46,5 +46,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// template <class BinaryPred> void unique(BinaryPred pred); // before C++20
// template <class BinaryPred> size_type unique(BinaryPred pred); // C++20 and later
// template <class BinaryPred> size_type unique(BinaryPred pred); // C++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@ -18,18 +18,18 @@
#include "test_macros.h"
#include "min_allocator.h"
bool g(int x, int y) { return x == y; }
TEST_CONSTEXPR bool g(int x, int y) { return x == y; }
struct PredLWG526 {
PredLWG526(int i) : i_(i) {}
~PredLWG526() { i_ = -32767; }
bool operator()(const PredLWG526& lhs, const PredLWG526& rhs) const { return lhs.i_ == rhs.i_; }
TEST_CONSTEXPR_CXX20 PredLWG526(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 ~PredLWG526() { i_ = -32767; }
TEST_CONSTEXPR bool operator()(const PredLWG526& lhs, const PredLWG526& rhs) const { return lhs.i_ == rhs.i_; }
bool operator==(int i) const { return i == i_; }
TEST_CONSTEXPR bool operator==(int i) const { return i == i_; }
int i_;
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
@ -75,5 +75,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -9,7 +9,7 @@
// <list>
// template <class T, class Alloc>
// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
// void swap(list<T,Alloc>& x, list<T,Alloc>& y); // constexpr since C++26
#include <list>
#include <cassert>
@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@ -133,5 +133,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -12,7 +12,7 @@
// void swap(list& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
// __is_nothrow_swappable<allocator_type>::value); // constexpr since C++26
//
// In C++17, the standard says that swap shall have:
// noexcept(allocator_traits<Allocator>::is_always_equal::value);
@ -52,7 +52,7 @@ struct some_alloc2 {
typedef std::true_type is_always_equal;
};
int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<MoveOnly> C;
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
@ -84,5 +84,14 @@ int main(int, char**) {
}
#endif
return true;
}
int main(int, char**) {
assert(test());
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}

View File

@ -24,6 +24,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@ -54,6 +58,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@ -87,6 +95,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@ -126,6 +138,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@ -171,6 +187,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifndef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should be defined in c++23"
# endif
@ -219,6 +239,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
# endif
# ifndef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should be defined in c++26"
# endif
# if __cpp_lib_constexpr_list != 202502L
# error "__cpp_lib_constexpr_list should have the value 202502L in c++26"
# endif
# ifndef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should be defined in c++26"
# endif

View File

@ -208,6 +208,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@ -1100,6 +1104,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@ -2094,6 +2102,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@ -3334,6 +3346,10 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++20"
# endif
@ -4790,6 +4806,10 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++23"
# endif
# ifdef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should not be defined before c++26"
# endif
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++23"
# endif
@ -6468,6 +6488,13 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++26"
# endif
# ifndef __cpp_lib_constexpr_list
# error "__cpp_lib_constexpr_list should be defined in c++26"
# endif
# if __cpp_lib_constexpr_list != 202502L
# error "__cpp_lib_constexpr_list should have the value 202502L in c++26"
# endif
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++26"
# endif

View File

@ -22,384 +22,381 @@
#include "test_macros.h"
template <class T>
class bare_allocator
{
class bare_allocator {
public:
typedef T value_type;
typedef T value_type;
bare_allocator() TEST_NOEXCEPT {}
bare_allocator() TEST_NOEXCEPT {}
template <class U>
bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
template <class U>
bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
T* allocate(std::size_t n)
{
return static_cast<T*>(::operator new(n*sizeof(T)));
}
T* allocate(std::size_t n) { return static_cast<T*>(::operator new(n * sizeof(T))); }
void deallocate(T* p, std::size_t)
{
return ::operator delete(static_cast<void*>(p));
}
void deallocate(T* p, std::size_t) { return ::operator delete(static_cast<void*>(p)); }
friend bool operator==(bare_allocator, bare_allocator) {return true;}
friend bool operator!=(bare_allocator x, bare_allocator y) {return !(x == y);}
friend bool operator==(bare_allocator, bare_allocator) { return true; }
friend bool operator!=(bare_allocator x, bare_allocator y) { return !(x == y); }
};
template <class T>
class no_default_allocator
{
class no_default_allocator {
#if TEST_STD_VER >= 11
no_default_allocator() = delete;
no_default_allocator() = delete;
#else
no_default_allocator();
no_default_allocator();
#endif
struct construct_tag {};
explicit no_default_allocator(construct_tag) {}
struct construct_tag {};
TEST_CONSTEXPR_CXX20 explicit no_default_allocator(construct_tag) {}
public:
static no_default_allocator create() {
construct_tag tag;
return no_default_allocator(tag);
}
TEST_CONSTEXPR_CXX20 static no_default_allocator create() {
construct_tag tag;
return no_default_allocator(tag);
}
public:
typedef T value_type;
typedef T value_type;
template <class U>
no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
template <class U>
TEST_CONSTEXPR_CXX20 no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
T* allocate(std::size_t n)
{
return static_cast<T*>(::operator new(n*sizeof(T)));
}
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return static_cast<T*>(std::allocator<T>().allocate(n)); }
void deallocate(T* p, std::size_t)
{
return ::operator delete(static_cast<void*>(p));
}
TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
friend bool operator==(no_default_allocator, no_default_allocator) {return true;}
friend bool operator!=(no_default_allocator x, no_default_allocator y) {return !(x == y);}
friend TEST_CONSTEXPR bool operator==(no_default_allocator, no_default_allocator) { return true; }
friend TEST_CONSTEXPR bool operator!=(no_default_allocator x, no_default_allocator y) { return !(x == y); }
};
struct malloc_allocator_base {
static std::size_t outstanding_bytes;
static std::size_t alloc_count;
static std::size_t dealloc_count;
static bool disable_default_constructor;
static std::size_t outstanding_bytes;
static std::size_t alloc_count;
static std::size_t dealloc_count;
static bool disable_default_constructor;
static std::size_t outstanding_alloc() {
assert(alloc_count >= dealloc_count);
return (alloc_count - dealloc_count);
}
static std::size_t outstanding_alloc() {
assert(alloc_count >= dealloc_count);
return (alloc_count - dealloc_count);
}
static void reset() {
assert(outstanding_alloc() == 0);
disable_default_constructor = false;
outstanding_bytes = 0;
alloc_count = 0;
dealloc_count = 0;
}
static void reset() {
assert(outstanding_alloc() == 0);
disable_default_constructor = false;
outstanding_bytes = 0;
alloc_count = 0;
dealloc_count = 0;
}
};
size_t malloc_allocator_base::outstanding_bytes = 0;
size_t malloc_allocator_base::alloc_count = 0;
size_t malloc_allocator_base::dealloc_count = 0;
size_t malloc_allocator_base::outstanding_bytes = 0;
size_t malloc_allocator_base::alloc_count = 0;
size_t malloc_allocator_base::dealloc_count = 0;
bool malloc_allocator_base::disable_default_constructor = false;
template <class T>
class malloc_allocator : public malloc_allocator_base
{
class malloc_allocator : public malloc_allocator_base {
public:
typedef T value_type;
typedef T value_type;
malloc_allocator() TEST_NOEXCEPT { assert(!disable_default_constructor); }
malloc_allocator() TEST_NOEXCEPT { assert(!disable_default_constructor); }
template <class U>
malloc_allocator(malloc_allocator<U>) TEST_NOEXCEPT {}
template <class U>
malloc_allocator(malloc_allocator<U>) TEST_NOEXCEPT {}
T* allocate(std::size_t n)
{
const std::size_t nbytes = n*sizeof(T);
++alloc_count;
outstanding_bytes += nbytes;
return static_cast<T*>(std::malloc(nbytes));
}
T* allocate(std::size_t n) {
const std::size_t nbytes = n * sizeof(T);
++alloc_count;
outstanding_bytes += nbytes;
return static_cast<T*>(std::malloc(nbytes));
}
void deallocate(T* p, std::size_t n)
{
const std::size_t nbytes = n*sizeof(T);
++dealloc_count;
outstanding_bytes -= nbytes;
std::free(static_cast<void*>(p));
}
void deallocate(T* p, std::size_t n) {
const std::size_t nbytes = n * sizeof(T);
++dealloc_count;
outstanding_bytes -= nbytes;
std::free(static_cast<void*>(p));
}
friend bool operator==(malloc_allocator, malloc_allocator) {return true;}
friend bool operator!=(malloc_allocator x, malloc_allocator y) {return !(x == y);}
friend bool operator==(malloc_allocator, malloc_allocator) { return true; }
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;
struct cpp03_allocator : bare_allocator<T> {
typedef T value_type;
typedef value_type* pointer;
static bool construct_called;
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;
}
// 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);
}
std::size_t max_size() const { return UINT_MAX / sizeof(T); }
};
template <class T> bool cpp03_allocator<T>::construct_called = false;
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;
struct cpp03_overload_allocator : bare_allocator<T> {
typedef T value_type;
typedef value_type* pointer;
static bool construct_called;
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;
}
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);
}
std::size_t max_size() const { return UINT_MAX / sizeof(T); }
};
template <class T> bool cpp03_overload_allocator<T>::construct_called = false;
template <class T>
bool cpp03_overload_allocator<T>::construct_called = false;
template <class T, class = std::integral_constant<std::size_t, 0> > class min_pointer;
template <class T, class ID> class min_pointer<const T, ID>;
template <class ID> class min_pointer<void, ID>;
template <class ID> class min_pointer<const void, ID>;
template <class T> class min_allocator;
template <class T, class = std::integral_constant<std::size_t, 0> >
class min_pointer;
template <class T, class ID>
class min_pointer<const T, ID>;
template <class ID>
class min_pointer<void, ID>;
template <class ID>
class min_pointer<const void, ID>;
template <class T>
class min_allocator;
template <class ID>
class min_pointer<const void, ID>
{
const void* ptr_;
class min_pointer<const void, ID> {
const void* ptr_;
public:
min_pointer() TEST_NOEXCEPT = default;
min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T>
min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
min_pointer() TEST_NOEXCEPT = default;
min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T>
min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
explicit operator bool() const {return ptr_ != nullptr;}
explicit operator bool() const { return ptr_ != nullptr; }
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U, class XID> friend class min_pointer;
friend bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
friend bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
template <class U, class XID>
friend class min_pointer;
};
template <class ID>
class min_pointer<void, ID>
{
void* ptr_;
class min_pointer<void, ID> {
void* ptr_;
public:
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T,
class = typename std::enable_if
<
!std::is_const<T>::value
>::type
>
TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T, class = typename std::enable_if< !std::is_const<T>::value >::type >
TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
TEST_CONSTEXPR_CXX14 friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
TEST_CONSTEXPR_CXX14 friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U, class XID> friend class min_pointer;
TEST_CONSTEXPR_CXX14 friend bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
TEST_CONSTEXPR_CXX14 friend bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
template <class U, class XID>
friend class min_pointer;
};
template <class T, class ID>
class min_pointer
{
T* ptr_;
class min_pointer {
T* ptr_;
TEST_CONSTEXPR_CXX14 explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
public:
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
typedef std::ptrdiff_t difference_type;
typedef T& reference;
typedef T* pointer;
typedef T value_type;
typedef std::random_access_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
typedef T& reference;
typedef T* pointer;
typedef T value_type;
typedef std::random_access_iterator_tag iterator_category;
TEST_CONSTEXPR_CXX14 reference operator*() const {return *ptr_;}
TEST_CONSTEXPR_CXX14 pointer operator->() const {return ptr_;}
TEST_CONSTEXPR_CXX14 reference operator*() const { return *ptr_; }
TEST_CONSTEXPR_CXX14 pointer operator->() const { return ptr_; }
TEST_CONSTEXPR_CXX14 min_pointer& operator++() {++ptr_; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
TEST_CONSTEXPR_CXX14 min_pointer& operator++() {
++ptr_;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {
min_pointer tmp(*this);
++ptr_;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator--() {--ptr_; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
TEST_CONSTEXPR_CXX14 min_pointer& operator--() {
--ptr_;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {
min_pointer tmp(*this);
--ptr_;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {
ptr_ += n;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {
ptr_ -= n;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const
{
min_pointer tmp(*this);
tmp += n;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const {
min_pointer tmp(*this);
tmp += n;
return tmp;
}
friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x)
{
return x + n;
}
friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x) { return x + n; }
TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const
{
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const {
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y)
{
return x.ptr_ - y.ptr_;
}
friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y) { return x.ptr_ - y.ptr_; }
TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const {return ptr_[n];}
TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const { return ptr_[n]; }
friend TEST_CONSTEXPR_CXX14 bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
friend TEST_CONSTEXPR_CXX14 bool operator> (min_pointer x, min_pointer y) {return y < x;}
friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
friend TEST_CONSTEXPR_CXX14 bool operator<(min_pointer x, min_pointer y) { return x.ptr_ < y.ptr_; }
friend TEST_CONSTEXPR_CXX14 bool operator>(min_pointer x, min_pointer y) { return y < x; }
friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) { return !(y < x); }
friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) { return !(x < y); }
static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(T& t) { return min_pointer(std::addressof(t)); }
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U, class XID> friend class min_pointer;
template <class U> friend class min_allocator;
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
template <class U, class XID>
friend class min_pointer;
template <class U>
friend class min_allocator;
};
template <class T, class ID>
class min_pointer<const T, ID>
{
const T* ptr_;
class min_pointer<const T, ID> {
const T* ptr_;
TEST_CONSTEXPR_CXX14 explicit min_pointer(const T* p) : ptr_(p) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(const T* p) : ptr_(p) {}
public:
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) : ptr_(nullptr) {}
TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) : ptr_(p.ptr_) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<const void, ID> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
min_pointer() TEST_NOEXCEPT = default;
TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) : ptr_(nullptr) {}
TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) : ptr_(p.ptr_) {}
TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<const void, ID> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
typedef std::ptrdiff_t difference_type;
typedef const T& reference;
typedef const T* pointer;
typedef const T value_type;
typedef std::random_access_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
typedef const T& reference;
typedef const T* pointer;
typedef const T value_type;
typedef std::random_access_iterator_tag iterator_category;
TEST_CONSTEXPR_CXX14 reference operator*() const {return *ptr_;}
TEST_CONSTEXPR_CXX14 pointer operator->() const {return ptr_;}
TEST_CONSTEXPR_CXX14 reference operator*() const { return *ptr_; }
TEST_CONSTEXPR_CXX14 pointer operator->() const { return ptr_; }
TEST_CONSTEXPR_CXX14 min_pointer& operator++() {++ptr_; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
TEST_CONSTEXPR_CXX14 min_pointer& operator++() {
++ptr_;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {
min_pointer tmp(*this);
++ptr_;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator--() {--ptr_; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
TEST_CONSTEXPR_CXX14 min_pointer& operator--() {
--ptr_;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {
min_pointer tmp(*this);
--ptr_;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {
ptr_ += n;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {
ptr_ -= n;
return *this;
}
TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const
{
min_pointer tmp(*this);
tmp += n;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const {
min_pointer tmp(*this);
tmp += n;
return tmp;
}
friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x)
{
return x + n;
}
friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x) { return x + n; }
TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const
{
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const {
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y)
{
return x.ptr_ - y.ptr_;
}
friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y) { return x.ptr_ - y.ptr_; }
TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const {return ptr_[n];}
TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const { return ptr_[n]; }
friend TEST_CONSTEXPR_CXX14 bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
friend TEST_CONSTEXPR_CXX14 bool operator> (min_pointer x, min_pointer y) {return y < x;}
friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
friend TEST_CONSTEXPR_CXX14 bool operator<(min_pointer x, min_pointer y) { return x.ptr_ < y.ptr_; }
friend TEST_CONSTEXPR_CXX14 bool operator>(min_pointer x, min_pointer y) { return y < x; }
friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) { return !(y < x); }
friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) { return !(x < y); }
static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(const T& t) { return min_pointer(std::addressof(t)); }
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) {return x.ptr_ != y.ptr_;}
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, std::nullptr_t) {return x.ptr_ == nullptr;}
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, std::nullptr_t) {return x.ptr_ != nullptr;}
friend TEST_CONSTEXPR_CXX14 bool operator==(std::nullptr_t, min_pointer x) {return x.ptr_ == nullptr;}
friend TEST_CONSTEXPR_CXX14 bool operator!=(std::nullptr_t, min_pointer x) {return x.ptr_ != nullptr;}
template <class U, class XID> friend class min_pointer;
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) { return x.ptr_ != y.ptr_; }
friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, std::nullptr_t) { return x.ptr_ == nullptr; }
friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, std::nullptr_t) { return x.ptr_ != nullptr; }
friend TEST_CONSTEXPR_CXX14 bool operator==(std::nullptr_t, min_pointer x) { return x.ptr_ == nullptr; }
friend TEST_CONSTEXPR_CXX14 bool operator!=(std::nullptr_t, min_pointer x) { return x.ptr_ != nullptr; }
template <class U, class XID>
friend class min_pointer;
};
template <class T>
class min_allocator
{
class min_allocator {
public:
typedef T value_type;
typedef min_pointer<T> pointer;
typedef T value_type;
typedef min_pointer<T> pointer;
min_allocator() = default;
template <class U>
TEST_CONSTEXPR_CXX20 min_allocator(min_allocator<U>) {}
min_allocator() = default;
template <class U>
TEST_CONSTEXPR_CXX20 min_allocator(min_allocator<U>) {}
TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator<T>().allocate(n)); }
TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator<T>().allocate(n)); }
TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) {return true;}
TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);}
TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) { return true; }
TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) { return !(x == y); }
};
template <class T>
@ -427,25 +424,19 @@ template <class T>
class explicit_allocator
{
public:
typedef T value_type;
typedef T value_type;
TEST_CONSTEXPR_CXX20 explicit_allocator() TEST_NOEXCEPT {}
TEST_CONSTEXPR_CXX20 explicit_allocator() TEST_NOEXCEPT {}
template <class U>
TEST_CONSTEXPR_CXX20 explicit explicit_allocator(explicit_allocator<U>) TEST_NOEXCEPT {}
template <class U>
TEST_CONSTEXPR_CXX20 explicit explicit_allocator(explicit_allocator<U>) TEST_NOEXCEPT {}
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n)
{
return static_cast<T*>(std::allocator<T>().allocate(n));
}
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return static_cast<T*>(std::allocator<T>().allocate(n)); }
TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n)
{
std::allocator<T>().deallocate(p, n);
}
TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
TEST_CONSTEXPR_CXX20 friend bool operator==(explicit_allocator, explicit_allocator) {return true;}
TEST_CONSTEXPR_CXX20 friend bool operator!=(explicit_allocator x, explicit_allocator y) {return !(x == y);}
TEST_CONSTEXPR_CXX20 friend bool operator==(explicit_allocator, explicit_allocator) { return true; }
TEST_CONSTEXPR_CXX20 friend bool operator!=(explicit_allocator x, explicit_allocator y) { return !(x == y); }
};
template <class T>

View File

@ -372,6 +372,11 @@ feature_test_macros = [
"values": {"c++20": 201811},
"headers": ["iterator"],
},
{
"name": "__cpp_lib_constexpr_list",
"values": {"c++26": 202502},
"headers": ["list"],
},
{
"name": "__cpp_lib_constexpr_memory",
"values": {"c++20": 201811, "c++23": 202202},