[libc++] Make forward_list constexpr as part of P3372R3 (#129435)
Fixes #128658
This commit is contained in:
@@ -420,6 +420,8 @@ Status
|
||||
---------------------------------------------------------- -----------------
|
||||
``__cpp_lib_constexpr_algorithms`` ``202306L``
|
||||
---------------------------------------------------------- -----------------
|
||||
``__cpp_lib_constexpr_forward_list`` ``202502L``
|
||||
---------------------------------------------------------- -----------------
|
||||
``__cpp_lib_constexpr_new`` ``202406L``
|
||||
---------------------------------------------------------- -----------------
|
||||
``__cpp_lib_constexpr_queue`` ``202502L``
|
||||
|
||||
@@ -49,24 +49,26 @@ struct __allocation_guard {
|
||||
using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;
|
||||
|
||||
template <class _AllocT> // we perform the allocator conversion inside the constructor
|
||||
_LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
|
||||
: __alloc_(std::move(__alloc)),
|
||||
__n_(__n),
|
||||
__ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
|
||||
{}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;
|
||||
_LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
|
||||
__allocation_guard(const __allocation_guard&) = delete;
|
||||
__allocation_guard& operator=(const __allocation_guard& __other) = delete;
|
||||
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
|
||||
: __alloc_(std::move(__other.__alloc_)),
|
||||
__n_(__other.__n_),
|
||||
__ptr_(__other.__ptr_) {
|
||||
__other.__ptr_ = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete;
|
||||
_LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT {
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
|
||||
operator=(__allocation_guard&& __other) _NOEXCEPT {
|
||||
if (std::addressof(__other) != this) {
|
||||
__destroy();
|
||||
|
||||
@@ -79,17 +81,17 @@ struct __allocation_guard {
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI _Pointer
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer
|
||||
__release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
|
||||
_Pointer __tmp = __ptr_;
|
||||
__ptr_ = nullptr;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
|
||||
|
||||
private:
|
||||
_LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
|
||||
if (__ptr_ != nullptr) {
|
||||
allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
|
||||
}
|
||||
|
||||
@@ -245,8 +245,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept {
|
||||
}
|
||||
|
||||
template <class _Pointer>
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr auto
|
||||
to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept
|
||||
-> decltype(std::__to_address(__p)) {
|
||||
return std::__to_address(__p);
|
||||
}
|
||||
#endif
|
||||
@@ -302,6 +302,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
|
||||
|
||||
#endif
|
||||
|
||||
// This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to
|
||||
// `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`,
|
||||
// then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer
|
||||
// to that object using the `std::pointer_traits<>::pinter_to` function.
|
||||
template <class _PtrTo, class _PtrFrom>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
|
||||
using __ptr_traits = pointer_traits<_PtrTo>;
|
||||
using __element_type = typename __ptr_traits::element_type;
|
||||
return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p)))
|
||||
: static_cast<_PtrTo>(nullptr);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -68,6 +68,7 @@ __cpp_lib_constexpr_charconv 202207L <charconv>
|
||||
__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
|
||||
__cpp_lib_constexpr_complex 201711L <complex>
|
||||
__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_memory 202202L <memory>
|
||||
@@ -543,6 +544,7 @@ __cpp_lib_void_t 201411L <type_traits>
|
||||
# define __cpp_lib_bitset 202306L
|
||||
# undef __cpp_lib_constexpr_algorithms
|
||||
# define __cpp_lib_constexpr_algorithms 202306L
|
||||
# define __cpp_lib_constexpr_forward_list 202502L
|
||||
# if !defined(_LIBCPP_ABI_VCRUNTIME)
|
||||
# define __cpp_lib_constexpr_new 202406L
|
||||
# endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// template<class T, class Allocator>
|
||||
// synth-three-way-result<T> operator<=>(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
|
||||
#include <cassert>
|
||||
#include <forward_list>
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test_sequence_container_spaceship<std::forward_list>());
|
||||
// `std::forward_list` is not constexpr, so no `static_assert` test here.
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test_sequence_container_spaceship<std::forward_list>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// class forward_list
|
||||
|
||||
// bool empty() const noexcept;
|
||||
// bool empty() const noexcept; // constexpr since C++26
|
||||
|
||||
#include <forward_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::forward_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;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,18 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// reference front();
|
||||
// const_reference front() const;
|
||||
// reference front(); // constexpr since C++26
|
||||
// const_reference front() const; // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -58,5 +59,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(const allocator_type& a);
|
||||
// explicit forward_list(const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "../../../NotConstructible.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef test_allocator<NotConstructible> A;
|
||||
typedef A::value_type T;
|
||||
@@ -26,5 +26,14 @@ int main(int, char**) {
|
||||
assert(c.empty());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
test();
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(const allocator_type& a);
|
||||
// explicit forward_list(const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "../../../NotConstructible.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef test_allocator<NotConstructible> A;
|
||||
typedef A::value_type T;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(const forward_list& x);
|
||||
// forward_list& operator=(const forward_list& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
@@ -143,5 +143,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;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void assign(initializer_list<value_type> il);
|
||||
// void assign(initializer_list<value_type> il); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -65,5 +65,14 @@ int main(int, char**) {
|
||||
assert(n == 4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(forward_list&& x);
|
||||
// forward_list& operator=(forward_list&& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -194,5 +194,14 @@ int main(int, char**) {
|
||||
assert(c0.empty());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(initializer_list<value_type> il);
|
||||
// forward_list& operator=(initializer_list<value_type> il); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -65,5 +65,14 @@ int main(int, char**) {
|
||||
assert(n == 4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// void assign(InputIterator first, InputIterator last);
|
||||
// void assign(InputIterator first, InputIterator last); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void assign(size_type n, const value_type& v);
|
||||
// void assign(size_type n, const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(const forward_list& x);
|
||||
// forward_list(const forward_list& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
@@ -64,5 +64,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(const forward_list& x, const allocator_type& a);
|
||||
// forward_list(const forward_list& x, const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
@@ -64,5 +64,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list();
|
||||
// forward_list(); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -38,5 +38,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;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
|
||||
|
||||
// template<container-compatible-range<T> R>
|
||||
// forward_list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23
|
||||
// forward_list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23; constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
#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::forward_list, int, Iter, Sent, Alloc>([](const auto&) {
|
||||
// No additional validation to do.
|
||||
@@ -26,8 +26,19 @@ int main(int, char**) {
|
||||
|
||||
static_assert(test_constraints<std::forward_list, int, double>());
|
||||
|
||||
test_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
test_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(initializer_list<value_type> il);
|
||||
// forward_list(initializer_list<value_type> il); // constexpr since C++26
|
||||
|
||||
#include <forward_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 int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -38,5 +38,14 @@ int main(int, char**) {
|
||||
assert(n == 10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(initializer_list<value_type> il, const allocator_type& a);
|
||||
// forward_list(initializer_list<value_type> il, const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -43,5 +43,14 @@ int main(int, char**) {
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(forward_list&& x);
|
||||
// forward_list(forward_list&& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -68,5 +68,14 @@ int main(int, char**) {
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(forward_list&& x, const allocator_type& a);
|
||||
// forward_list(forward_list&& x, const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -68,5 +68,14 @@ int main(int, char**) {
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// forward_list(InputIterator first, InputIterator last);
|
||||
// forward_list(InputIterator first, InputIterator last); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// template <class InputIterator>
|
||||
// forward_list(InputIterator first, InputIterator last,
|
||||
// const allocator_type& a);
|
||||
// const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -51,5 +51,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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(size_type n);
|
||||
// explicit forward_list(size_type n, const Alloc& a);
|
||||
// explicit forward_list(size_type n); // constexpr since C++26
|
||||
// explicit forward_list(size_type n, const Alloc& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(size_type n, const value_type& v);
|
||||
// forward_list(size_type n, const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> 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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(size_type n, const value_type& v, const allocator_type& a);
|
||||
// forward_list(size_type n, const value_type& v, const allocator_type& a); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef test_allocator<int> A;
|
||||
typedef A::value_type T;
|
||||
@@ -47,5 +47,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;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// template <class T, class Allocator, class U>
|
||||
// typename forward_list<T, Allocator>::size_type
|
||||
// erase(forward_list<T, Allocator>& c, const U& value);
|
||||
// erase(forward_list<T, Allocator>& c, const U& value); // constexpr since C++26
|
||||
|
||||
#include <forward_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 test() {
|
||||
test0(S(), 1, S(), 0);
|
||||
|
||||
test0(S({1}), 1, S(), 1);
|
||||
@@ -62,13 +62,21 @@ void test() {
|
||||
test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
test<std::forward_list<int>>();
|
||||
test<std::forward_list<int, min_allocator<int>>>();
|
||||
test<std::forward_list<int, test_allocator<int>>>();
|
||||
|
||||
test<std::forward_list<long>>();
|
||||
test<std::forward_list<double>>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// template <class T, class Allocator, class Predicate>
|
||||
// typename forward_list<T, Allocator>::size_type
|
||||
// erase_if(forward_list<T, Allocator>& c, Predicate pred);
|
||||
// erase_if(forward_list<T, Allocator>& c, Predicate pred); // constexpr since C++26
|
||||
|
||||
#include <forward_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 test() {
|
||||
auto is1 = [](auto v) { return v == 1; };
|
||||
auto is2 = [](auto v) { return v == 2; };
|
||||
auto is3 = [](auto v) { return v == 3; };
|
||||
@@ -64,13 +64,21 @@ void test() {
|
||||
test0(S({1, 2, 3}), False, S({1, 2, 3}), 0);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
test<std::forward_list<int>>();
|
||||
test<std::forward_list<int, min_allocator<int>>>();
|
||||
test<std::forward_list<int, test_allocator<int>>>();
|
||||
|
||||
test<std::forward_list<long>>();
|
||||
test<std::forward_list<double>>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator before_begin();
|
||||
// const_iterator before_begin() const;
|
||||
// const_iterator cbefore_begin() const;
|
||||
// iterator before_begin(); // constexpr since C++26
|
||||
// const_iterator before_begin() const; // constexpr since C++26
|
||||
// const_iterator cbefore_begin() const; // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
// <forward_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 <forward_list>
|
||||
#include <cassert>
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -69,6 +69,8 @@ int main(int, char**) {
|
||||
typedef std::forward_list<T> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
(void)i;
|
||||
(void)j;
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
@@ -117,6 +119,8 @@ int main(int, char**) {
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
(void)i;
|
||||
(void)j;
|
||||
}
|
||||
#endif
|
||||
#if TEST_STD_VER > 11
|
||||
@@ -142,5 +146,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// 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 <forward_list>
|
||||
|
||||
@@ -21,7 +21,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_assign_range<std::forward_list, int, double>());
|
||||
|
||||
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
|
||||
@@ -31,8 +31,19 @@ int main(int, char**) {
|
||||
});
|
||||
test_sequence_prepend_range_move_only<std::forward_list>();
|
||||
|
||||
test_prepend_range_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_prepend_range_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
test_prepend_range_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_prepend_range_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void clear() noexcept;
|
||||
// void clear() noexcept; // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "../../../NotConstructible.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef NotConstructible T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -64,5 +64,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;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_after(const_iterator p, Args&&... args);
|
||||
// iterator emplace_after(const_iterator p, Args&&... args); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -84,5 +84,14 @@ int main(int, char**) {
|
||||
assert(std::distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_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 <forward_list>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -67,5 +67,14 @@ int main(int, char**) {
|
||||
assert(std::distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator erase_after(const_iterator first, const_iterator last);
|
||||
// iterator erase_after(const_iterator first, const_iterator last); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -153,5 +153,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator erase_after(const_iterator p);
|
||||
// iterator erase_after(const_iterator p); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -95,5 +95,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, const value_type& v);
|
||||
// iterator insert_after(const_iterator p, const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> 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;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, initializer_list<value_type> il);
|
||||
// iterator insert_after(const_iterator p, initializer_list<value_type> il); // constexpr since C++26
|
||||
|
||||
#include <forward_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 int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -70,5 +70,14 @@ int main(int, char**) {
|
||||
assert(*std::next(c.begin(), 4) == 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// template <class InputIterator>
|
||||
// iterator insert_after(const_iterator p,
|
||||
// InputIterator first, InputIterator last);
|
||||
// InputIterator first, InputIterator last); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, value_type&& v);
|
||||
// iterator insert_after(const_iterator p, value_type&& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -85,5 +85,14 @@ int main(int, char**) {
|
||||
assert(std::distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, size_type n, const value_type& v);
|
||||
// iterator insert_after(const_iterator p, size_type n, const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -70,5 +70,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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
|
||||
|
||||
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=20000000
|
||||
|
||||
// template<container-compatible-range<T> R>
|
||||
// constexpr iterator insert_range_after(const_iterator position, R&& rg); // C++23
|
||||
// constexpr iterator insert_range_after(const_iterator position, R&& rg); // C++23; constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
@@ -321,7 +323,7 @@ constexpr void test_sequence_insert_range_after() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_sequence_insert_range_after_move_only() {
|
||||
TEST_CONSTEXPR_CXX26 void test_sequence_insert_range_after_move_only() {
|
||||
MoveOnly input[5];
|
||||
std::ranges::subrange in(std::move_iterator{input}, std::move_iterator{input + 5});
|
||||
|
||||
@@ -366,7 +368,7 @@ void test_insert_range_after_exception_safety_throwing_allocator() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
static_assert(test_constraints_insert_range_after<std::forward_list, int, double>());
|
||||
|
||||
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
|
||||
@@ -374,8 +376,19 @@ int main(int, char**) {
|
||||
});
|
||||
test_sequence_insert_range_after_move_only();
|
||||
|
||||
test_insert_range_after_exception_safety_throwing_copy();
|
||||
test_insert_range_after_exception_safety_throwing_allocator<int>();
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
test_insert_range_after_exception_safety_throwing_copy();
|
||||
test_insert_range_after_exception_safety_throwing_allocator<int>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void pop_front();
|
||||
// void pop_front(); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -71,5 +71,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// 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 <forward_list>
|
||||
|
||||
@@ -21,7 +21,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::forward_list, int, double>());
|
||||
|
||||
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
|
||||
@@ -31,8 +31,19 @@ int main(int, char**) {
|
||||
});
|
||||
test_sequence_prepend_range_move_only<std::forward_list>();
|
||||
|
||||
test_prepend_range_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_prepend_range_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
test_prepend_range_exception_safety_throwing_copy<std::forward_list>();
|
||||
test_prepend_range_exception_safety_throwing_allocator<std::forward_list, int>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(const value_type& v);
|
||||
// void push_front(const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -44,5 +44,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// UNSUPPORTED: no-exceptions
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(const value_type& x);
|
||||
// void push_front(const value_type& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(value_type&& v);
|
||||
// void push_front(value_type&& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -45,5 +45,14 @@ int main(int, char**) {
|
||||
assert(std::distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void resize(size_type n);
|
||||
// void resize(size_type n); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
{
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
@@ -65,7 +65,7 @@ int main(int, char**) {
|
||||
assert(*std::next(c.begin(), 5) == 0);
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
@@ -112,5 +112,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void resize(size_type n, const value_type& v);
|
||||
// void resize(size_type n, const value_type& v); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -22,7 +22,7 @@
|
||||
# include "container_test_types.h"
|
||||
#endif
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -84,7 +84,7 @@ int main(int, char**) {
|
||||
assert(*std::next(c.begin(), 4) == 10);
|
||||
assert(*std::next(c.begin(), 5) == 10);
|
||||
}
|
||||
{
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// Test that the allocator's construct method is being used to
|
||||
// construct the new elements and that it's called exactly N times.
|
||||
typedef std::forward_list<int, ContainerTestAllocator<int, int>> Container;
|
||||
@@ -99,5 +99,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void merge(forward_list& x);
|
||||
// void merge(forward_list& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -30,11 +30,11 @@ struct value {
|
||||
int a;
|
||||
int b;
|
||||
|
||||
friend bool operator<(const value& lhs, const value& rhs) { return lhs.a < rhs.a; }
|
||||
friend bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
friend TEST_CONSTEXPR bool operator<(const value& lhs, const value& rhs) { return lhs.a < rhs.a; }
|
||||
friend TEST_CONSTEXPR bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
};
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{ // Basic merge operation.
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -116,5 +116,14 @@ int main(int, char**) {
|
||||
assert(c == std::forward_list<int>(std::begin(a), std::end(a)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class Compare> void merge(forward_list& x, Compare comp);
|
||||
// template <class Compare> void merge(forward_list& x, Compare comp); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -30,11 +30,11 @@ struct value {
|
||||
int a;
|
||||
int b;
|
||||
|
||||
friend bool operator>(const value& lhs, const value& rhs) { return lhs.a > rhs.a; }
|
||||
friend bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
friend TEST_CONSTEXPR bool operator>(const value& lhs, const value& rhs) { return lhs.a > rhs.a; }
|
||||
friend TEST_CONSTEXPR bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
};
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{ // Basic merge operation.
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -117,5 +117,14 @@ int main(int, char**) {
|
||||
assert(c == std::forward_list<int>(std::begin(a), std::end(a)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void merge(forward_list&& x);
|
||||
// void merge(forward_list&& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <functional>
|
||||
@@ -29,11 +29,11 @@ struct value {
|
||||
int a;
|
||||
int b;
|
||||
|
||||
friend bool operator<(const value& lhs, const value& rhs) { return lhs.a < rhs.a; }
|
||||
friend bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
friend TEST_CONSTEXPR bool operator<(const value& lhs, const value& rhs) { return lhs.a < rhs.a; }
|
||||
friend TEST_CONSTEXPR bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
};
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{ // Basic merge operation.
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -109,5 +109,14 @@ int main(int, char**) {
|
||||
assert(c == std::forward_list<int>(std::begin(a), std::end(a)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class Compare> void merge(forward_list&& x, Compare comp);
|
||||
// template <class Compare> void merge(forward_list&& x, Compare comp); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <functional>
|
||||
@@ -29,11 +29,11 @@ struct value {
|
||||
int a;
|
||||
int b;
|
||||
|
||||
friend bool operator>(const value& lhs, const value& rhs) { return lhs.a > rhs.a; }
|
||||
friend bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
friend TEST_CONSTEXPR bool operator>(const value& lhs, const value& rhs) { return lhs.a > rhs.a; }
|
||||
friend TEST_CONSTEXPR bool operator==(const value& lhs, const value& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }
|
||||
};
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{ // Basic merge operation.
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -110,5 +110,14 @@ int main(int, char**) {
|
||||
assert(c == std::forward_list<int>(std::begin(a), std::end(a)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// void remove(const value_type& v); // C++17 and before
|
||||
// size_type remove(const value_type& v); // C++20 and after
|
||||
// size_type remove(const value_type& v); // C++20 and after; // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class L>
|
||||
void do_remove(L& l, const typename L::value_type& value, typename L::size_type expected) {
|
||||
TEST_CONSTEXPR_CXX26 void do_remove(L& l, const typename L::value_type& value, typename L::size_type expected) {
|
||||
typename L::size_type old_size = std::distance(l.begin(), l.end());
|
||||
#if TEST_STD_VER > 17
|
||||
ASSERT_SAME_TYPE(decltype(l.remove(value)), typename L::size_type);
|
||||
@@ -32,22 +32,22 @@ void do_remove(L& l, const typename L::value_type& value, typename L::size_type
|
||||
}
|
||||
|
||||
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_CXX20 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() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -171,5 +171,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class Predicate> void remove_if(Predicate pred); // C++17 and before
|
||||
// template <class Predicate> size_type remove_if(Predicate pred); // C++20 and after
|
||||
// template <class Predicate> size_type remove_if(Predicate pred); // C++20 and after; constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "counting_predicates.h"
|
||||
|
||||
template <class L, class Predicate>
|
||||
void do_remove_if(L& l, Predicate pred, typename L::size_type expected) {
|
||||
TEST_CONSTEXPR_CXX26 void do_remove_if(L& l, Predicate pred, typename L::size_type expected) {
|
||||
typename L::size_type old_size = std::distance(l.begin(), l.end());
|
||||
#if TEST_STD_VER > 17
|
||||
ASSERT_SAME_TYPE(decltype(l.remove_if(pred)), typename L::size_type);
|
||||
@@ -34,18 +34,18 @@ void do_remove_if(L& l, Predicate pred, typename L::size_type expected) {
|
||||
assert(old_size - std::distance(l.begin(), l.end()) == expected);
|
||||
}
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool (*)(T), T> Predicate;
|
||||
@@ -187,5 +187,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void reverse();
|
||||
// void reverse(); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N) {
|
||||
TEST_CONSTEXPR_CXX26 void test1(int N) {
|
||||
C c;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c.push_front(i);
|
||||
@@ -30,12 +30,21 @@ void test(int N) {
|
||||
assert(*j == i);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
for (int i = 0; i < 10; ++i)
|
||||
test<std::forward_list<int> >(i);
|
||||
test1<std::forward_list<int> >(i);
|
||||
#if TEST_STD_VER >= 11
|
||||
for (int i = 0; i < 10; ++i)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i);
|
||||
test1<std::forward_list<int, min_allocator<int>> >(i);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x);
|
||||
// void splice_after(const_iterator p, forward_list&& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,13 +19,13 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef int T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
TEST_CONSTEXPR const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
TEST_CONSTEXPR const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void testd(const C& c, int p, int l) {
|
||||
TEST_CONSTEXPR_CXX26 void testd(const C& c, int p, int l) {
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
@@ -37,7 +37,7 @@ void testd(const C& c, int p, int l) {
|
||||
assert(std::distance(c.begin(), c.end()) == size_t1 + l);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -67,5 +67,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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
|
||||
// void splice_after(const_iterator p, forward_list&& x, const_iterator i); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,13 +19,13 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef int T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12};
|
||||
const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
TEST_CONSTEXPR const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
TEST_CONSTEXPR const T t2[] = {10, 11, 12};
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void testd(const C& c, int p, int f) {
|
||||
TEST_CONSTEXPR_CXX26 void testd(const C& c, int p, int f) {
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
@@ -38,7 +38,7 @@ void testd(const C& c, int p, int f) {
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void tests(const C& c, int p, int f) {
|
||||
TEST_CONSTEXPR_CXX26 void tests(const C& c, int p, int f) {
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n = 0;
|
||||
if (p == f || p == f + 1) {
|
||||
@@ -67,7 +67,7 @@ void tests(const C& c, int p, int f) {
|
||||
assert(std::distance(c.begin(), c.end()) == size_t1);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -117,5 +117,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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=3000000
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x,
|
||||
// const_iterator first, const_iterator last);
|
||||
// const_iterator first, const_iterator last); // constexpr since C++26
|
||||
|
||||
#include <stddef.h>
|
||||
#include <forward_list>
|
||||
@@ -20,13 +22,13 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef std::ptrdiff_t T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
TEST_CONSTEXPR const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
TEST_CONSTEXPR const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1);
|
||||
TEST_CONSTEXPR const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void testd(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
TEST_CONSTEXPR_CXX26 void testd(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
typename C::const_iterator i = c.begin();
|
||||
std::ptrdiff_t n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
@@ -39,7 +41,7 @@ void testd(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void tests(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
TEST_CONSTEXPR_CXX26 void tests(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
typename C::const_iterator i = c.begin();
|
||||
std::ptrdiff_t n = 0;
|
||||
std::ptrdiff_t d = l > f + 1 ? l - 1 - f : 0;
|
||||
@@ -69,7 +71,7 @@ void tests(const C& c, std::ptrdiff_t p, ptrdiff_t f, ptrdiff_t l) {
|
||||
assert(std::distance(c.begin(), c.end()) == size_t1);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -157,5 +159,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// void unique(); // C++17 and before
|
||||
// size_type unique(); // C++20 and after
|
||||
// size_type unique(); // C++20 and after; constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class L>
|
||||
void do_unique(L& l, typename L::size_type expected) {
|
||||
TEST_CONSTEXPR_CXX26 void do_unique(L& l, typename L::size_type expected) {
|
||||
typename L::size_type old_size = std::distance(l.begin(), l.end());
|
||||
#if TEST_STD_VER > 17
|
||||
ASSERT_SAME_TYPE(decltype(l.unique()), typename L::size_type);
|
||||
@@ -31,7 +31,7 @@ void do_unique(L& l, typename L::size_type expected) {
|
||||
assert(old_size - std::distance(l.begin(), l.end()) == expected);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -131,5 +131,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred); // C++17 and before
|
||||
// template <class BinaryPredicate> size_type unique(BinaryPredicate binary_pred); // C++20 and after
|
||||
// template <class BinaryPredicate> size_type unique(BinaryPredicate binary_pred); // C++20 and after; constexpr since C++26
|
||||
|
||||
#include <cassert>
|
||||
#include <forward_list>
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class L, class Predicate>
|
||||
void do_unique(L& l, Predicate pred, typename L::size_type expected) {
|
||||
TEST_CONSTEXPR_CXX26 void do_unique(L& l, Predicate pred, typename L::size_type expected) {
|
||||
typename L::size_type old_size = std::distance(l.begin(), l.end());
|
||||
#if TEST_STD_VER > 17
|
||||
ASSERT_SAME_TYPE(decltype(l.unique(pred)), typename L::size_type);
|
||||
@@ -33,17 +33,17 @@ void do_unique(L& l, Predicate pred, typename L::size_type expected) {
|
||||
}
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
bool g(int x, int y) { return x == y; }
|
||||
TEST_CONSTEXPR bool g(int x, int y) { return x == y; }
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
@@ -157,5 +157,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;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// bool operator==(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator!=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N, int M) {
|
||||
TEST_CONSTEXPR_CXX26 void test(int N, int M) {
|
||||
C c1;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c1.push_front(i);
|
||||
@@ -44,7 +44,7 @@ void test(int N, int M) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int> >(i, j);
|
||||
@@ -54,5 +54,14 @@ int main(int, char**) {
|
||||
test<std::forward_list<int, min_allocator<int>> >(i, j);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void swap(forward_list& x);
|
||||
// void swap(forward_list& x); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -257,5 +257,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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <forward_list>
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
|
||||
// void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
@@ -258,5 +258,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;
|
||||
}
|
||||
|
||||
@@ -10,19 +10,19 @@
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// bool operator< (const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator> (const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator>=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator<=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
// const forward_list<T, Allocator>& y); // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N, int M) {
|
||||
TEST_CONSTEXPR_CXX26 void test(int N, int M) {
|
||||
C c1;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c1.push_front(i);
|
||||
@@ -50,7 +50,7 @@ void test(int N, int M) {
|
||||
assert(c1 > c2);
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int> >(i, j);
|
||||
@@ -60,5 +60,14 @@ int main(int, char**) {
|
||||
test<std::forward_list<int, min_allocator<int>> >(i, j);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
// void swap(forward_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(is_always_equal<allocator_type>::value);
|
||||
// noexcept(is_always_equal<allocator_type>::value); // constexpr since C++26
|
||||
|
||||
// This tests a conforming extension
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// class forward_list
|
||||
|
||||
// allocator_type get_allocator() const
|
||||
// allocator_type get_allocator() const // constexpr since C++26
|
||||
|
||||
#include <forward_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::forward_list<int> fl(alloc);
|
||||
@@ -30,5 +30,14 @@ int main(int, char**) {
|
||||
assert(fl.get_allocator() == alloc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
assert(test());
|
||||
#if TEST_STD_VER >= 26
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list()
|
||||
// forward_list::iterator()
|
||||
// forward_list::const_iterator()
|
||||
// forward_list() // constexpr since C++26
|
||||
// forward_list::iterator() // constexpr since C++26
|
||||
// forward_list::const_iterator() // constexpr since C++26
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
@@ -33,7 +33,7 @@ struct B {
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int, char**) {
|
||||
TEST_CONSTEXPR_CXX26 bool test() {
|
||||
{
|
||||
A a;
|
||||
assert(a.d.empty());
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// size_type max_size() const;
|
||||
// size_type max_size() const; // constexpr since C++26
|
||||
|
||||
#include <cassert>
|
||||
#include <forward_list>
|
||||
@@ -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::forward_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;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_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_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_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_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_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_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_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_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_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_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_constexpr_forward_list != 202502L
|
||||
# error "__cpp_lib_constexpr_forward_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
|
||||
|
||||
@@ -196,6 +196,10 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should not be defined before c++26"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
|
||||
# endif
|
||||
@@ -1084,6 +1088,10 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should not be defined before c++26"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
|
||||
# endif
|
||||
@@ -2074,6 +2082,10 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should not be defined before c++26"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
|
||||
# endif
|
||||
@@ -3304,6 +3316,10 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should not be defined before c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should be defined in c++20"
|
||||
# endif
|
||||
@@ -4756,6 +4772,10 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++23"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should not be defined before c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should be defined in c++23"
|
||||
# endif
|
||||
@@ -6427,6 +6447,13 @@
|
||||
# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_constexpr_forward_list
|
||||
# error "__cpp_lib_constexpr_forward_list should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_constexpr_forward_list != 202502L
|
||||
# error "__cpp_lib_constexpr_forward_list should have the value 202502L in c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_constexpr_functional
|
||||
# error "__cpp_lib_constexpr_functional should be defined in c++26"
|
||||
# endif
|
||||
|
||||
@@ -16,42 +16,44 @@
|
||||
template <typename Predicate, typename Arg>
|
||||
struct unary_counting_predicate {
|
||||
public:
|
||||
typedef Arg argument_type;
|
||||
typedef bool result_type;
|
||||
typedef Arg argument_type;
|
||||
typedef bool result_type;
|
||||
|
||||
unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
|
||||
unary_counting_predicate(const unary_counting_predicate&) = default;
|
||||
unary_counting_predicate& operator=(const unary_counting_predicate&) = default;
|
||||
~unary_counting_predicate() {}
|
||||
TEST_CONSTEXPR_CXX20 unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
|
||||
unary_counting_predicate(const unary_counting_predicate&) = default;
|
||||
unary_counting_predicate& operator=(const unary_counting_predicate&) = default;
|
||||
TEST_CONSTEXPR_CXX20 ~unary_counting_predicate() {}
|
||||
|
||||
bool operator () (const Arg &a) const { ++count_; return p_(a); }
|
||||
std::size_t count() const { return count_; }
|
||||
void reset() { count_ = 0; }
|
||||
TEST_CONSTEXPR_CXX14 bool operator()(const Arg& a) const {
|
||||
++count_;
|
||||
return p_(a);
|
||||
}
|
||||
TEST_CONSTEXPR std::size_t count() const { return count_; }
|
||||
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
|
||||
|
||||
private:
|
||||
Predicate p_;
|
||||
mutable std::size_t count_;
|
||||
Predicate p_;
|
||||
mutable std::size_t count_;
|
||||
};
|
||||
|
||||
|
||||
template <typename Predicate, typename Arg1, typename Arg2=Arg1>
|
||||
template <typename Predicate, typename Arg1, typename Arg2 = Arg1>
|
||||
struct binary_counting_predicate {
|
||||
public:
|
||||
typedef Arg1 first_argument_type;
|
||||
typedef Arg2 second_argument_type;
|
||||
typedef bool result_type;
|
||||
typedef Arg1 first_argument_type;
|
||||
typedef Arg2 second_argument_type;
|
||||
typedef bool result_type;
|
||||
|
||||
TEST_CONSTEXPR binary_counting_predicate(Predicate p) : p_(p), count_(0) {}
|
||||
TEST_CONSTEXPR_CXX14 bool operator()(const Arg1& a1, const Arg2& a2) const {
|
||||
++count_;
|
||||
return p_(a1, a2);
|
||||
}
|
||||
TEST_CONSTEXPR std::size_t count() const { return count_; }
|
||||
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
|
||||
TEST_CONSTEXPR binary_counting_predicate(Predicate p) : p_(p), count_(0) {}
|
||||
TEST_CONSTEXPR_CXX14 bool operator()(const Arg1& a1, const Arg2& a2) const {
|
||||
++count_;
|
||||
return p_(a1, a2);
|
||||
}
|
||||
TEST_CONSTEXPR std::size_t count() const { return count_; }
|
||||
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
|
||||
|
||||
private:
|
||||
Predicate p_;
|
||||
mutable std::size_t count_;
|
||||
private:
|
||||
Predicate p_;
|
||||
mutable std::size_t count_;
|
||||
};
|
||||
|
||||
#if TEST_STD_VER > 14
|
||||
@@ -66,13 +68,13 @@ public:
|
||||
constexpr counting_predicate(Predicate pred, int& count) : pred_(std::move(pred)), count_(&count) {}
|
||||
|
||||
template <class... Args>
|
||||
constexpr decltype(auto) operator()(Args&& ...args) {
|
||||
constexpr decltype(auto) operator()(Args&&... args) {
|
||||
++(*count_);
|
||||
return pred_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
constexpr decltype(auto) operator()(Args&& ...args) const {
|
||||
constexpr decltype(auto) operator()(Args&&... args) const {
|
||||
++(*count_);
|
||||
return pred_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
5
libcxx/utils/generate_feature_test_macro_components.py
Executable file → Normal file
5
libcxx/utils/generate_feature_test_macro_components.py
Executable file → Normal file
@@ -357,6 +357,11 @@ feature_test_macros = [
|
||||
"values": {"c++20": 201907},
|
||||
"headers": ["memory"],
|
||||
},
|
||||
{
|
||||
"name": "__cpp_lib_constexpr_forward_list",
|
||||
"values": {"c++26": 202502},
|
||||
"headers": ["forward_list"],
|
||||
},
|
||||
{
|
||||
"name": "__cpp_lib_constexpr_functional",
|
||||
"values": {"c++20": 201907},
|
||||
|
||||
Reference in New Issue
Block a user