Remove the `STATIC_ASSERT` macro from tests where it is unnecessary (#4588)

This commit is contained in:
A. Jiang 2024-04-19 08:13:15 +08:00 коммит произвёл GitHub
Родитель a35fb2a84c
Коммит a58d716887
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
149 изменённых файлов: 8210 добавлений и 8239 удалений

Просмотреть файл

@ -14,8 +14,6 @@
#include <is_permissive.hpp>
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
namespace ranges = std::ranges;
template <class>
@ -47,7 +45,7 @@ struct boolish {
template <class T, std::size_t N>
struct holder {
STATIC_ASSERT(N < ~std::size_t{0} / sizeof(T));
static_assert(N < ~std::size_t{0} / sizeof(T));
alignas(T) unsigned char space[N * sizeof(T)];
@ -69,12 +67,12 @@ namespace test {
template <class T>
void operator&(T&&) {
STATIC_ASSERT(always_false<T>);
static_assert(always_false<T>);
}
template <class T, class U>
void operator,(T&&, U&&) {
STATIC_ASSERT(always_false<T>);
static_assert(always_false<T>);
}
enum class CanDifference : bool { no, yes };
@ -103,7 +101,7 @@ namespace test {
template <class T>
[[nodiscard]] constexpr bool to_bool(T const t) noexcept {
STATIC_ASSERT(std::is_enum_v<T> && std::same_as<std::underlying_type_t<T>, bool>);
static_assert(std::is_enum_v<T> && std::same_as<std::underlying_type_t<T>, bool>);
return static_cast<bool>(t);
}
@ -492,29 +490,29 @@ namespace test {
}
auto operator--() & {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
auto operator--(int) & {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
friend void iter_swap(iterator const&, iterator const&)
requires std::is_same_v<Category, output>
{
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
void operator<(iterator const&) const {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
void operator>(iterator const&) const {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
void operator<=(iterator const&) const {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
void operator>=(iterator const&) const {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
// input iterator operations:
@ -928,11 +926,11 @@ namespace test {
}
void operator&() const {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
template <class T>
friend void operator,(range const&, T&&) {
STATIC_ASSERT(always_false<Category>);
static_assert(always_false<Category>);
}
};
} // namespace test

Просмотреть файл

@ -56,8 +56,6 @@
using namespace std;
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#pragma warning(push)
#pragma warning(disable : 4582) // 'uninit_vector::storage': constructor is not implicitly called
#pragma warning(disable : 4583) // 'uninit_vector::storage': destructor is not implicitly called

Просмотреть файл

@ -10,8 +10,6 @@
using namespace std;
using namespace std::placeholders;
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
class point {
public:
point(double x, double y) : m_x(x), m_y(y) {}

Просмотреть файл

@ -51,27 +51,27 @@ void test_unwrappable_range() {
constexpr bool is_const_unwrappable = requires(const It& ci) { ci._Unwrapped(); };
if constexpr (is_const_unwrappable) {
STATIC_ASSERT(same_as<decltype(declval<It>()._Unwrapped()), decltype(declval<const It&>()._Unwrapped())>);
static_assert(same_as<decltype(declval<It>()._Unwrapped()), decltype(declval<const It&>()._Unwrapped())>);
}
STATIC_ASSERT(ranges::_Unwrappable_sentinel_for<Se, It>);
static_assert(ranges::_Unwrappable_sentinel_for<Se, It>);
STATIC_ASSERT(same_as<ranges::_Unwrap_iter_t<It, Se>, decltype(declval<It>()._Unwrapped())>);
static_assert(same_as<ranges::_Unwrap_iter_t<It, Se>, decltype(declval<It>()._Unwrapped())>);
if constexpr (is_const_unwrappable) {
STATIC_ASSERT(same_as<ranges::_Unwrap_iter_t<const It&, Se>, decltype(declval<It>()._Unwrapped())>);
static_assert(same_as<ranges::_Unwrap_iter_t<const It&, Se>, decltype(declval<It>()._Unwrapped())>);
}
STATIC_ASSERT(same_as<ranges::_Unwrap_sent_t<Se, It>, decltype(declval<Se>()._Unwrapped())>);
STATIC_ASSERT(same_as<ranges::_Unwrap_sent_t<const Se&, It>, decltype(declval<Se>()._Unwrapped())>);
static_assert(same_as<ranges::_Unwrap_sent_t<Se, It>, decltype(declval<Se>()._Unwrapped())>);
static_assert(same_as<ranges::_Unwrap_sent_t<const Se&, It>, decltype(declval<Se>()._Unwrapped())>);
STATIC_ASSERT(noexcept(ranges::_Unwrap_iter<Se>(declval<It>())) == noexcept(declval<It>()._Unwrapped()));
static_assert(noexcept(ranges::_Unwrap_iter<Se>(declval<It>())) == noexcept(declval<It>()._Unwrapped()));
if constexpr (is_const_unwrappable) {
STATIC_ASSERT(
static_assert(
noexcept(ranges::_Unwrap_iter<Se>(declval<const It&>())) == noexcept(declval<const It&>()._Unwrapped()));
}
STATIC_ASSERT(noexcept(ranges::_Unwrap_sent<It>(declval<Se>())) == noexcept(declval<Se>()._Unwrapped()));
STATIC_ASSERT(
static_assert(noexcept(ranges::_Unwrap_sent<It>(declval<Se>())) == noexcept(declval<Se>()._Unwrapped()));
static_assert(
noexcept(ranges::_Unwrap_sent<It>(declval<const Se&>())) == noexcept(declval<const Se&>()._Unwrapped()));
// instantiate without calling
@ -84,18 +84,18 @@ void test_not_unwrappable_range() {
using It = ranges::iterator_t<Rng>;
using Se = ranges::sentinel_t<Rng>;
STATIC_ASSERT(!ranges::_Unwrappable_sentinel_for<Se, It>);
STATIC_ASSERT(same_as<ranges::_Unwrap_iter_t<It, Se>, It>);
STATIC_ASSERT(same_as<ranges::_Unwrap_iter_t<const It&, Se>, It>);
static_assert(!ranges::_Unwrappable_sentinel_for<Se, It>);
static_assert(same_as<ranges::_Unwrap_iter_t<It, Se>, It>);
static_assert(same_as<ranges::_Unwrap_iter_t<const It&, Se>, It>);
STATIC_ASSERT(same_as<ranges::_Unwrap_sent_t<Se, It>, Se>);
STATIC_ASSERT(same_as<ranges::_Unwrap_sent_t<const Se&, It>, Se>);
static_assert(same_as<ranges::_Unwrap_sent_t<Se, It>, Se>);
static_assert(same_as<ranges::_Unwrap_sent_t<const Se&, It>, Se>);
STATIC_ASSERT(noexcept(ranges::_Unwrap_iter<Se>(declval<It>())));
STATIC_ASSERT(noexcept(ranges::_Unwrap_iter<Se>(declval<const It&>())));
static_assert(noexcept(ranges::_Unwrap_iter<Se>(declval<It>())));
static_assert(noexcept(ranges::_Unwrap_iter<Se>(declval<const It&>())));
STATIC_ASSERT(noexcept(ranges::_Unwrap_sent<It>(declval<Se>())));
STATIC_ASSERT(noexcept(ranges::_Unwrap_sent<It>(declval<const Se&>())));
static_assert(noexcept(ranges::_Unwrap_sent<It>(declval<Se>())));
static_assert(noexcept(ranges::_Unwrap_sent<It>(declval<const Se&>())));
// instantiate without calling
void (*p)(Rng&) = test_algorithms<Rng>;

Просмотреть файл

@ -79,8 +79,6 @@ public:
#include "test_macros.h"
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
namespace bad_variant_access {
int run_test() {
static_assert(std::is_base_of<std::exception, std::bad_variant_access>::value,
@ -7112,21 +7110,21 @@ namespace msvc {
};
struct __declspec(empty_bases) many_bases : empty<0>, empty<1>, empty<2>, empty<3> {};
STATIC_ASSERT(check_size<bool>);
STATIC_ASSERT(check_size<char>);
STATIC_ASSERT(check_size<unsigned char>);
STATIC_ASSERT(check_size<int>);
STATIC_ASSERT(check_size<unsigned int>);
STATIC_ASSERT(check_size<long>);
STATIC_ASSERT(check_size<long long>);
STATIC_ASSERT(check_size<float>);
STATIC_ASSERT(check_size<double>);
STATIC_ASSERT(check_size<void*>);
STATIC_ASSERT(check_size<empty<0>>);
STATIC_ASSERT(check_size<not_empty>);
STATIC_ASSERT(check_size<many_bases>);
static_assert(check_size<bool>);
static_assert(check_size<char>);
static_assert(check_size<unsigned char>);
static_assert(check_size<int>);
static_assert(check_size<unsigned int>);
static_assert(check_size<long>);
static_assert(check_size<long long>);
static_assert(check_size<float>);
static_assert(check_size<double>);
static_assert(check_size<void*>);
static_assert(check_size<empty<0>>);
static_assert(check_size<not_empty>);
static_assert(check_size<many_bases>);
STATIC_ASSERT(check_size<bool, char, short, int, long, long long, float, double, long double, void*, empty<0>,
static_assert(check_size<bool, char, short, int, long, long long, float, double, long double, void*, empty<0>,
empty<1>, not_empty, many_bases>);
} // namespace size
@ -7527,12 +7525,12 @@ namespace msvc {
{
using V = std::variant<int>;
constexpr V v(42);
STATIC_ASSERT(std::visit<int>(obj, v) == 42);
static_assert(std::visit<int>(obj, v) == 42);
}
{
using V = std::variant<short, long, char>;
constexpr V v(42l);
STATIC_ASSERT(std::visit<long>(obj, v) == 42);
static_assert(std::visit<long>(obj, v) == 42);
}
{
using V1 = std::variant<int>;
@ -7541,7 +7539,7 @@ namespace msvc {
constexpr V1 v1;
constexpr V2 v2(nullptr);
constexpr V3 v3;
STATIC_ASSERT(std::visit<double>(aobj, v1, v2, v3) == 3.0);
static_assert(std::visit<double>(aobj, v1, v2, v3) == 3.0);
}
{
using V1 = std::variant<int>;
@ -7550,7 +7548,7 @@ namespace msvc {
constexpr V1 v1;
constexpr V2 v2(nullptr);
constexpr V3 v3;
STATIC_ASSERT(std::visit<long long>(aobj, v1, v2, v3) == 3LL);
static_assert(std::visit<long long>(aobj, v1, v2, v3) == 3LL);
}
{
using V = std::variant<simple_derived<0>, simple_derived<1>, simple_derived<2>>;
@ -7763,7 +7761,7 @@ namespace msvc {
// Verify that `_Meta_at_<_Meta_list<>, size_t(-1)>` has no member named `type`, and that instantiating it doesn't
// consume the entire compiler heap.
STATIC_ASSERT(!has_type<std::_Meta_at_<std::_Meta_list<>, static_cast<std::size_t>(-1)>>);
static_assert(!has_type<std::_Meta_at_<std::_Meta_list<>, static_cast<std::size_t>(-1)>>);
namespace vso468746 {
// Defend against regression of VSO-468746
@ -7802,9 +7800,9 @@ namespace msvc {
static constexpr V v1(&intVar);
static constexpr V v2(&doubleVar);
STATIC_ASSERT(v1.index() == 0);
static_assert(v1.index() == 0);
assert(*std::get<0>(v1) == 42);
STATIC_ASSERT(v2.index() == 1);
static_assert(v2.index() == 1);
assert(*std::get<1>(v2) == 3.14);
}
} // namespace vso492097
@ -7894,9 +7892,9 @@ namespace msvc {
{
std::variant<const int> oc{};
oc.emplace<0>(0);
STATIC_ASSERT(!std::is_copy_assignable_v<decltype(oc)>);
STATIC_ASSERT(!std::is_move_assignable_v<decltype(oc)>);
STATIC_ASSERT(!std::is_swappable_v<decltype(oc)>);
static_assert(!std::is_copy_assignable_v<decltype(oc)>);
static_assert(!std::is_move_assignable_v<decltype(oc)>);
static_assert(!std::is_swappable_v<decltype(oc)>);
std::variant<volatile int> ov{};
std::variant<volatile int> ov2{};
@ -7907,9 +7905,9 @@ namespace msvc {
std::variant<const volatile int> ocv{};
ocv.emplace<0>(0);
STATIC_ASSERT(!std::is_copy_assignable_v<decltype(ocv)>);
STATIC_ASSERT(!std::is_move_assignable_v<decltype(ocv)>);
STATIC_ASSERT(!std::is_swappable_v<decltype(ocv)>);
static_assert(!std::is_copy_assignable_v<decltype(ocv)>);
static_assert(!std::is_move_assignable_v<decltype(ocv)>);
static_assert(!std::is_swappable_v<decltype(ocv)>);
}
{
std::variant<const CvAssignable> oc{};

Просмотреть файл

@ -2478,7 +2478,6 @@ int run_test() {
#include <cassert>
#include "test_macros.h"
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
namespace nonmembers::swap_ {
int run_test()
@ -2713,52 +2712,52 @@ namespace msvc {
constexpr bool IsBig = !(std::_Any_is_small<T> || std::_Any_is_trivial<T>);
void run_test() {
STATIC_ASSERT(!IsBig<small>);
STATIC_ASSERT(!IsBig<void*>);
STATIC_ASSERT(IsBig<large>);
static_assert(!IsBig<small>);
static_assert(!IsBig<void*>);
static_assert(IsBig<large>);
{
// Verify that a type that meets the size requirement *exactly* and has a lesser alignment requirement
// is considered small.
using T = SizeAndAlignType<BufferSize, 1>;
STATIC_ASSERT(sizeof(T) == BufferSize);
STATIC_ASSERT(alignof(T) < BufferAlignment);
STATIC_ASSERT(!IsBig<T>);
static_assert(sizeof(T) == BufferSize);
static_assert(alignof(T) < BufferAlignment);
static_assert(!IsBig<T>);
}
{
// Verify that a type that meets the alignment requirement *exactly* and has a lesser size is considered
// small.
using T = SizeAndAlignType<BufferAlignment, BufferAlignment>;
STATIC_ASSERT(sizeof(T) <= BufferSize);
STATIC_ASSERT(alignof(T) == BufferAlignment);
STATIC_ASSERT(!IsBig<T>);
static_assert(sizeof(T) <= BufferSize);
static_assert(alignof(T) == BufferAlignment);
static_assert(!IsBig<T>);
}
{
// Verify that a type that meets the size and alignment requirements *exactly* is considered small.
using T = SizeAndAlignType<align_to<BufferAlignment>(BufferSize), BufferAlignment>;
STATIC_ASSERT(sizeof(T) <= BufferSize);
STATIC_ASSERT(alignof(T) == BufferAlignment);
STATIC_ASSERT(!IsBig<T>);
static_assert(sizeof(T) <= BufferSize);
static_assert(alignof(T) == BufferAlignment);
static_assert(!IsBig<T>);
}
{
// Verify that a type that meets the alignment requirements but is over-sized is not considered small.
using T = SizeAndAlignType<BufferSize + 1, 1>;
STATIC_ASSERT(sizeof(T) > BufferSize);
STATIC_ASSERT(alignof(T) < BufferAlignment);
STATIC_ASSERT(IsBig<T>);
static_assert(sizeof(T) > BufferSize);
static_assert(alignof(T) < BufferAlignment);
static_assert(IsBig<T>);
}
{
// Verify that a type that meets the size requirements but is over-aligned is not considered small.
using T = SizeAndAlignType<BufferAlignment * 2, BufferAlignment * 2>;
STATIC_ASSERT(alignof(T) >= BufferSize || sizeof(T) < BufferSize);
STATIC_ASSERT(alignof(T) > BufferAlignment);
STATIC_ASSERT(IsBig<T>);
static_assert(alignof(T) >= BufferSize || sizeof(T) < BufferSize);
static_assert(alignof(T) > BufferAlignment);
static_assert(IsBig<T>);
}
{
// Verify that a type that exceeds both the size and alignment requirements is not considered small.
using T = SizeAndAlignType<BufferSize + 1, BufferAlignment * 2>;
STATIC_ASSERT(sizeof(T) > BufferSize);
STATIC_ASSERT(alignof(T) > BufferAlignment);
STATIC_ASSERT(IsBig<T>);
static_assert(sizeof(T) > BufferSize);
static_assert(alignof(T) > BufferAlignment);
static_assert(IsBig<T>);
}
}
} // namespace small_type

Просмотреть файл

@ -39,8 +39,6 @@
#include <msvc_stdlib_force_include.h> // Must precede any other libc++ headers
#include <stdlib.h>
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
// clang-format off
// LLVM SOURCES BEGIN
// -- BEGIN: test/std/utilities/utility/utility.inplace/inplace.pass.cpp
@ -8116,19 +8114,19 @@ namespace msvc {
template <class T>
constexpr bool check_size = sizeof(std::optional<T>) == sizeof(T) + alignof(T);
STATIC_ASSERT(check_size<bool>);
STATIC_ASSERT(check_size<char>);
STATIC_ASSERT(check_size<unsigned char>);
STATIC_ASSERT(check_size<int>);
STATIC_ASSERT(check_size<unsigned int>);
STATIC_ASSERT(check_size<long>);
STATIC_ASSERT(check_size<long long>);
STATIC_ASSERT(check_size<float>);
STATIC_ASSERT(check_size<double>);
STATIC_ASSERT(check_size<void*>);
STATIC_ASSERT(check_size<empty<0>>);
STATIC_ASSERT(check_size<not_empty>);
STATIC_ASSERT(check_size<many_bases>);
static_assert(check_size<bool>);
static_assert(check_size<char>);
static_assert(check_size<unsigned char>);
static_assert(check_size<int>);
static_assert(check_size<unsigned int>);
static_assert(check_size<long>);
static_assert(check_size<long long>);
static_assert(check_size<float>);
static_assert(check_size<double>);
static_assert(check_size<void*>);
static_assert(check_size<empty<0>>);
static_assert(check_size<not_empty>);
static_assert(check_size<many_bases>);
} // namespace size
namespace lwg2842 {
@ -8142,15 +8140,15 @@ namespace msvc {
// ConvertibleFromInPlace is not default constructible, so these constructions do not match
// optional(in_place_t, args...). They will match the converting constructor template if it does not properly
// reject arguments that decay to std::in_place_t as required by LWG-2842.
STATIC_ASSERT(!is_constructible_v<O, in_place_t>);
STATIC_ASSERT(!is_constructible_v<O, in_place_t&>);
STATIC_ASSERT(!is_constructible_v<O, const in_place_t>);
STATIC_ASSERT(!is_constructible_v<O, const in_place_t&>);
static_assert(!is_constructible_v<O, in_place_t>);
static_assert(!is_constructible_v<O, in_place_t&>);
static_assert(!is_constructible_v<O, const in_place_t>);
static_assert(!is_constructible_v<O, const in_place_t&>);
} // namespace lwg2842
namespace lwg3836 {
STATIC_ASSERT(std::is_convertible_v<std::optional<int>, std::optional<bool>>);
STATIC_ASSERT(std::is_convertible_v<const std::optional<int>&, std::optional<bool>>);
static_assert(std::is_convertible_v<std::optional<int>, std::optional<bool>>);
static_assert(std::is_convertible_v<const std::optional<int>&, std::optional<bool>>);
#if _HAS_CXX20
#define CONSTEXPR20 constexpr
@ -8168,7 +8166,7 @@ namespace msvc {
#undef CONSTEXPR20
#if _HAS_CXX20
STATIC_ASSERT(run_test());
static_assert(run_test());
#endif // _HAS_CXX20
} // namespace lwg3836
@ -8194,8 +8192,8 @@ namespace msvc {
// Defend against regression of VSO-508126
void run_test() {
struct S {};
STATIC_ASSERT(!std::is_copy_constructible_v<volatile S>);
STATIC_ASSERT(!std::is_copy_constructible_v<std::optional<volatile S>>);
static_assert(!std::is_copy_constructible_v<volatile S>);
static_assert(!std::is_copy_constructible_v<std::optional<volatile S>>);
}
} // namespace vso508126
@ -8306,9 +8304,9 @@ namespace msvc {
{
std::optional<const int> oc{};
oc.emplace(0);
STATIC_ASSERT(!std::is_copy_assignable_v<decltype(oc)>);
STATIC_ASSERT(!std::is_move_assignable_v<decltype(oc)>);
STATIC_ASSERT(!std::is_swappable_v<decltype(oc)>);
static_assert(!std::is_copy_assignable_v<decltype(oc)>);
static_assert(!std::is_move_assignable_v<decltype(oc)>);
static_assert(!std::is_swappable_v<decltype(oc)>);
std::optional<volatile int> ov{};
std::optional<volatile int> ov2{};
@ -8319,9 +8317,9 @@ namespace msvc {
std::optional<const volatile int> ocv{};
ocv.emplace(0);
STATIC_ASSERT(!std::is_copy_assignable_v<decltype(ocv)>);
STATIC_ASSERT(!std::is_move_assignable_v<decltype(ocv)>);
STATIC_ASSERT(!std::is_swappable_v<decltype(ocv)>);
static_assert(!std::is_copy_assignable_v<decltype(ocv)>);
static_assert(!std::is_move_assignable_v<decltype(ocv)>);
static_assert(!std::is_swappable_v<decltype(ocv)>);
}
{
std::optional<const CvAssignable> oc{};

Просмотреть файл

@ -10,44 +10,42 @@ using std::lcm;
constexpr auto int_min = std::numeric_limits<int>::min();
constexpr auto int_max = std::numeric_limits<int>::max();
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
static_assert(gcd(0, 0) == 0);
static_assert(gcd(0, 1) == 1);
static_assert(gcd(1, 0) == 1);
static_assert(gcd(0, 1) == 1);
static_assert(gcd(60, 24) == 12);
static_assert(gcd(196, 42) == 14);
static_assert(gcd(54, 24) == 6);
STATIC_ASSERT(gcd(0, 0) == 0);
STATIC_ASSERT(gcd(0, 1) == 1);
STATIC_ASSERT(gcd(1, 0) == 1);
STATIC_ASSERT(gcd(0, 1) == 1);
STATIC_ASSERT(gcd(60, 24) == 12);
STATIC_ASSERT(gcd(196, 42) == 14);
STATIC_ASSERT(gcd(54, 24) == 6);
static_assert(gcd(0, -1) == 1);
static_assert(gcd(-1, 0) == 1);
static_assert(gcd(0, -1) == 1);
static_assert(gcd(-60, -24) == 12);
static_assert(gcd(-196, -42) == 14);
static_assert(gcd(-54, -24) == 6);
STATIC_ASSERT(gcd(0, -1) == 1);
STATIC_ASSERT(gcd(-1, 0) == 1);
STATIC_ASSERT(gcd(0, -1) == 1);
STATIC_ASSERT(gcd(-60, -24) == 12);
STATIC_ASSERT(gcd(-196, -42) == 14);
STATIC_ASSERT(gcd(-54, -24) == 6);
static_assert(gcd(0, 1) == 1);
static_assert(gcd(-1, 0) == 1);
static_assert(gcd(0, 1) == 1);
static_assert(gcd(-60, 24) == 12);
static_assert(gcd(-196, 42) == 14);
static_assert(gcd(-54, 24) == 6);
STATIC_ASSERT(gcd(0, 1) == 1);
STATIC_ASSERT(gcd(-1, 0) == 1);
STATIC_ASSERT(gcd(0, 1) == 1);
STATIC_ASSERT(gcd(-60, 24) == 12);
STATIC_ASSERT(gcd(-196, 42) == 14);
STATIC_ASSERT(gcd(-54, 24) == 6);
STATIC_ASSERT(gcd(1073741824, 536870912) == 536870912);
STATIC_ASSERT(gcd(1073741824, -536870912) == 536870912);
STATIC_ASSERT(gcd(-1073741824, 536870912) == 536870912);
STATIC_ASSERT(gcd(int_max, int_max) == int_max);
STATIC_ASSERT(gcd(int_min, int_max) == 1);
static_assert(gcd(1073741824, 536870912) == 536870912);
static_assert(gcd(1073741824, -536870912) == 536870912);
static_assert(gcd(-1073741824, 536870912) == 536870912);
static_assert(gcd(int_max, int_max) == int_max);
static_assert(gcd(int_min, int_max) == 1);
// gcd(int_min, int_min) -> undefined behavior
STATIC_ASSERT(gcd(int_min + 1, int_min + 1) == int_max);
static_assert(gcd(int_min + 1, int_min + 1) == int_max);
STATIC_ASSERT(gcd(4294967296ULL, 65536L) == 65536ULL);
STATIC_ASSERT(gcd(4294967296ULL, 65536UL) == 65536ULL);
static_assert(gcd(4294967296ULL, 65536L) == 65536ULL);
static_assert(gcd(4294967296ULL, 65536UL) == 65536ULL);
STATIC_ASSERT(lcm(0, 0) == 0);
STATIC_ASSERT(lcm(0, 1) == 0);
STATIC_ASSERT(lcm(1, 0) == 0);
STATIC_ASSERT(lcm(1073741824, 536870912) == 1073741824);
STATIC_ASSERT(lcm(1073741824, -536870912) == 1073741824);
STATIC_ASSERT(lcm(-1073741824, 536870912) == 1073741824);
static_assert(lcm(0, 0) == 0);
static_assert(lcm(0, 1) == 0);
static_assert(lcm(1, 0) == 0);
static_assert(lcm(1073741824, 536870912) == 1073741824);
static_assert(lcm(1073741824, -536870912) == 1073741824);
static_assert(lcm(-1073741824, 536870912) == 1073741824);

Просмотреть файл

@ -11,11 +11,9 @@
using namespace std;
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
template <class T, class E, size_t N>
constexpr void assert_equal(T&& actual, const array<E, N>& expected) {
STATIC_ASSERT(is_same_v<T, array<E, N>>);
static_assert(is_same_v<T, array<E, N>>);
assert(actual == expected);
}

Просмотреть файл

@ -45,23 +45,23 @@ struct instantiator {
{
using iconcept = iterator_traits<Cit>::iterator_concept;
if constexpr (forward_iterator<Iter>) {
STATIC_ASSERT(same_as<iconcept, forward_iterator_tag>);
static_assert(same_as<iconcept, forward_iterator_tag>);
} else {
STATIC_ASSERT(same_as<typename iterator_traits<Cit>::iterator_concept, input_iterator_tag>);
static_assert(same_as<typename iterator_traits<Cit>::iterator_concept, input_iterator_tag>);
}
using icat = iterator_traits<Cit>::iterator_category;
if constexpr (derived_from<icat, forward_iterator_tag>) {
STATIC_ASSERT(same_as<icat, forward_iterator_tag>);
static_assert(same_as<icat, forward_iterator_tag>);
} else {
STATIC_ASSERT(same_as<icat, input_iterator_tag>);
static_assert(same_as<icat, input_iterator_tag>);
}
using ipointer = iterator_traits<Cit>::pointer;
if constexpr (CanArrow<Cit>) {
STATIC_ASSERT(same_as<ipointer, decltype(declval<const Cit&>().operator->())>);
static_assert(same_as<ipointer, decltype(declval<const Cit&>().operator->())>);
} else {
STATIC_ASSERT(same_as<ipointer, void>);
static_assert(same_as<ipointer, void>);
}
}
@ -225,11 +225,11 @@ struct input_copy_but_no_eq {
bool operator==(default_sentinel_t) const;
};
STATIC_ASSERT(input_iterator<input_copy_but_no_eq>);
STATIC_ASSERT(no_iterator_traits<input_copy_but_no_eq>);
STATIC_ASSERT(sentinel_for<default_sentinel_t, input_copy_but_no_eq>);
static_assert(input_iterator<input_copy_but_no_eq>);
static_assert(no_iterator_traits<input_copy_but_no_eq>);
static_assert(sentinel_for<default_sentinel_t, input_copy_but_no_eq>);
using ICID = iterator_traits<common_iterator<input_copy_but_no_eq, default_sentinel_t>>;
STATIC_ASSERT(same_as<typename ICID::iterator_category, input_iterator_tag>);
static_assert(same_as<typename ICID::iterator_category, input_iterator_tag>);
struct poor_sentinel {
poor_sentinel() = default;

Просмотреть файл

@ -50,7 +50,7 @@ struct instantiator {
int input[5] = {1, 2, 3, 4, 5};
// [counted.iter.const]
{
STATIC_ASSERT(default_initializable<counted_iterator<Iter>> == default_initializable<Iter>);
static_assert(default_initializable<counted_iterator<Iter>> == default_initializable<Iter>);
if constexpr (default_initializable<Iter>) {
[[maybe_unused]] counted_iterator<Iter> defaultConstructed{};
}
@ -202,8 +202,8 @@ struct instantiator {
const same_as<iter_difference_t<Iter>> auto diff1 = counted_iterator<Iter>{} - counted_iterator<Iter>{};
assert(diff1 == 0);
}
STATIC_ASSERT(CountedCompare<Iter, ConstIter> == common_with<Iter, ConstIter>);
STATIC_ASSERT(CountedCompare<ConstIter, Iter> == common_with<Iter, ConstIter>);
static_assert(CountedCompare<Iter, ConstIter> == common_with<Iter, ConstIter>);
static_assert(CountedCompare<ConstIter, Iter> == common_with<Iter, ConstIter>);
if constexpr (common_with<Iter, ConstIter>) { // cross-type difference
counted_iterator<Iter> iter1{Iter{input + 1}, 2};
@ -341,7 +341,7 @@ void test_P2259() {
}
int main() {
STATIC_ASSERT(with_writable_iterators<instantiator, int>::call());
static_assert(with_writable_iterators<instantiator, int>::call());
with_writable_iterators<instantiator, int>::call();
{ // Validate unwrapping

Просмотреть файл

@ -16,8 +16,8 @@ constexpr void smoke_test() {
using P = std::pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(adjacent_find(borrowed<false>{}, ranges::equal_to{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(adjacent_find(borrowed<true>{}, ranges::equal_to{})), int*>);
static_assert(same_as<decltype(adjacent_find(borrowed<false>{}, ranges::equal_to{})), ranges::dangling>);
static_assert(same_as<decltype(adjacent_find(borrowed<true>{}, ranges::equal_to{})), int*>);
const std::array pairs = {P{0, 42}, P{1, 42}, P{2, 42}, P{4, 42}, P{5, 42}};
const auto pred = [](const int x, const int y) { return y - x > 1; };
@ -25,31 +25,31 @@ constexpr void smoke_test() {
{
// Validate range overload [found case]
const auto result = adjacent_find(pairs, pred, get_first);
STATIC_ASSERT(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
static_assert(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
assert(result == pairs.begin() + 2);
}
{
// Validate iterator + sentinel overload [found case]
const auto result = adjacent_find(pairs.begin(), pairs.end(), pred, get_first);
STATIC_ASSERT(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
static_assert(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
assert(result == pairs.begin() + 2);
}
{
// Validate range overload [not found case]
const auto result = adjacent_find(pairs, ranges::equal_to{}, get_first);
STATIC_ASSERT(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
static_assert(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
assert(result == pairs.end());
}
{
// Validate iterator + sentinel overload [not found case]
const auto result = adjacent_find(pairs.begin(), pairs.end(), ranges::equal_to{}, get_first);
STATIC_ASSERT(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
static_assert(same_as<decltype(result), const iterator_t<decltype(pairs)>>);
assert(result == pairs.end());
}
}
int main() {
STATIC_ASSERT((smoke_test(), true));
static_assert((smoke_test(), true));
smoke_test();
}

Просмотреть файл

@ -27,7 +27,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = all_of(wrapped_input1.begin(), wrapped_input1.end(), is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!all_of(wrapped_input2.begin(), wrapped_input2.end(), is_even, get_second));
assert(!all_of(wrapped_input3.begin(), wrapped_input3.end(), is_odd, get_first));
@ -40,7 +40,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = all_of(wrapped_input1, is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!all_of(wrapped_input2, is_even, get_second));
assert(!all_of(wrapped_input3, is_odd, get_first));
@ -50,6 +50,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -27,7 +27,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = any_of(wrapped_input1.begin(), wrapped_input1.end(), is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!any_of(wrapped_input2.begin(), wrapped_input2.end(), is_even, get_second));
assert(any_of(wrapped_input3.begin(), wrapped_input3.end(), is_odd, get_first));
@ -40,7 +40,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = any_of(wrapped_input1, is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!any_of(wrapped_input2, is_even, get_second));
assert(any_of(wrapped_input3, is_odd, get_first));
@ -50,6 +50,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -18,12 +18,12 @@ using namespace std;
#define ASSERT(...) assert((__VA_ARGS__))
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::lower_bound(borrowed<false>{}, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::lower_bound(borrowed<true>{}, 42)), int*>);
STATIC_ASSERT(same_as<decltype(ranges::upper_bound(borrowed<false>{}, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::upper_bound(borrowed<true>{}, 42)), int*>);
STATIC_ASSERT(same_as<decltype(ranges::equal_range(borrowed<false>{}, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::equal_range(borrowed<true>{}, 42)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::lower_bound(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::lower_bound(borrowed<true>{}, 42)), int*>);
static_assert(same_as<decltype(ranges::upper_bound(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::upper_bound(borrowed<true>{}, 42)), int*>);
static_assert(same_as<decltype(ranges::equal_range(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::equal_range(borrowed<true>{}, 42)), ranges::subrange<int*>>);
using P = pair<int, int>;
@ -170,18 +170,18 @@ struct binary_search_instantiator {
};
int main() {
STATIC_ASSERT((test_fwd<empty_ranges, const P>(), true));
static_assert((test_fwd<empty_ranges, const P>(), true));
test_fwd<empty_ranges, const P>();
STATIC_ASSERT((test_fwd<lower_bound_instantiator, const P>(), true));
static_assert((test_fwd<lower_bound_instantiator, const P>(), true));
test_fwd<lower_bound_instantiator, const P>();
STATIC_ASSERT((test_fwd<upper_bound_instantiator, const P>(), true));
static_assert((test_fwd<upper_bound_instantiator, const P>(), true));
test_fwd<upper_bound_instantiator, const P>();
STATIC_ASSERT((test_fwd<equal_range_instantiator, const P>(), true));
static_assert((test_fwd<equal_range_instantiator, const P>(), true));
test_fwd<equal_range_instantiator, const P>();
STATIC_ASSERT((test_fwd<binary_search_instantiator, const P>(), true));
static_assert((test_fwd<binary_search_instantiator, const P>(), true));
test_fwd<binary_search_instantiator, const P>();
}

Просмотреть файл

@ -12,12 +12,12 @@
using namespace std;
// Validate that copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::copy(borrowed<false>{}, nullptr_to<int>)), ranges::copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::copy(borrowed<true>{}, nullptr_to<int>)), ranges::copy_result<int*, int*>>);
static_assert(same_as<decltype(ranges::copy(borrowed<true>{}, nullptr_to<int>)), ranges::copy_result<int*, int*>>);
struct instantiator {
static constexpr int input[3] = {13, 42, 1729};
@ -30,7 +30,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = copy(wrapped_input.begin(), wrapped_input.end(), Write{output});
STATIC_ASSERT(same_as<decltype(result), copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, input));
@ -40,7 +40,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = copy(wrapped_input, Write{output});
STATIC_ASSERT(same_as<decltype(result), copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, input));
@ -49,6 +49,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in_write<instantiator, int const, int>(), true));
static_assert((test_in_write<instantiator, int const, int>(), true));
test_in_write<instantiator, int const, int>();
}

Просмотреть файл

@ -12,12 +12,12 @@
using namespace std;
// Validate that copy_backward_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::copy_backward_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::copy_backward_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::copy_backward(borrowed<false>{}, static_cast<int*>(nullptr))),
static_assert(same_as<decltype(ranges::copy_backward(borrowed<false>{}, static_cast<int*>(nullptr))),
ranges::copy_backward_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::copy_backward(borrowed<true>{}, static_cast<int*>(nullptr))),
static_assert(same_as<decltype(ranges::copy_backward(borrowed<true>{}, static_cast<int*>(nullptr))),
ranges::copy_backward_result<int*, int*>>);
static constexpr int input[] = {13, 42, 1729};
@ -36,7 +36,7 @@ struct instantiator {
int output[] = {-2, -2, -2};
Bidi2 wrapped_output{output};
auto result = copy_backward(wrapped_input, wrapped_output.end());
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
static_assert(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
assert(result.in == wrapped_input.end());
assert(result.out == wrapped_output.begin());
assert(equal(output, input));
@ -45,7 +45,7 @@ struct instantiator {
int output[] = {-2, -2, -2};
Bidi2 wrapped_output{output};
auto result = copy_backward(wrapped_input.begin(), wrapped_input.end(), wrapped_output.end());
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
static_assert(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
assert(result.in == wrapped_input.end());
assert(result.out == wrapped_output.begin());
assert(equal(output, input));
@ -55,7 +55,7 @@ struct instantiator {
Bidi1 in{span{io}.first<3>()};
Bidi2 out{span{io}.last<3>()};
auto result = copy_backward(in, out.end());
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
static_assert(same_as<decltype(result), copy_backward_result<iterator_t<Bidi1>, iterator_t<Bidi2>>>);
assert(result.in == in.end());
assert(result.out == out.begin());
assert(equal(io, expected_overlapping));
@ -72,7 +72,7 @@ constexpr void test_memmove() {
{ // Validate range overload
int output[] = {-2, -2, -2};
auto result = copy_backward(input, end(output));
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<const int*, int*>>);
static_assert(same_as<decltype(result), copy_backward_result<const int*, int*>>);
assert(result.in == end(input));
assert(result.out == begin(output));
assert(equal(output, input));
@ -80,7 +80,7 @@ constexpr void test_memmove() {
{ // Validate iterator + sentinel overload
int output[] = {-2, -2, -2};
auto result = copy_backward(begin(input), end(input), end(output));
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<const int*, int*>>);
static_assert(same_as<decltype(result), copy_backward_result<const int*, int*>>);
assert(result.in == end(input));
assert(result.out == begin(output));
assert(equal(output, input));
@ -88,7 +88,7 @@ constexpr void test_memmove() {
{ // Validate overlapping ranges
int io[] = {0, 1, 2, 42};
auto result = copy_backward(io + 0, io + 3, io + 4);
STATIC_ASSERT(same_as<decltype(result), copy_backward_result<int*, int*>>);
static_assert(same_as<decltype(result), copy_backward_result<int*, int*>>);
assert(result.in == io + 3);
assert(result.out == io + 1);
assert(equal(io, expected_overlapping));
@ -96,9 +96,9 @@ constexpr void test_memmove() {
}
int main() {
STATIC_ASSERT((test_bidi_bidi<instantiator, const int, int>(), true));
static_assert((test_bidi_bidi<instantiator, const int, int>(), true));
test_bidi_bidi<instantiator, const int, int>();
STATIC_ASSERT((test_memmove(), true));
static_assert((test_memmove(), true));
test_memmove();
}

Просмотреть файл

@ -24,7 +24,7 @@ struct not_pair {
if constexpr (I == 0) {
return np.first;
} else {
STATIC_ASSERT(I == 1);
static_assert(I == 1);
return np.second;
}
}
@ -33,7 +33,7 @@ struct not_pair {
if constexpr (I == 0) {
return np.first;
} else {
STATIC_ASSERT(I == 1);
static_assert(I == 1);
return np.second;
}
}
@ -42,7 +42,7 @@ struct not_pair {
if constexpr (I == 0) {
return move(np).first;
} else {
STATIC_ASSERT(I == 1);
static_assert(I == 1);
return move(np).second;
}
}
@ -51,7 +51,7 @@ struct not_pair {
if constexpr (I == 0) {
return move(np).first;
} else {
STATIC_ASSERT(I == 1);
static_assert(I == 1);
return move(np).second;
}
}
@ -62,12 +62,12 @@ using P = not_pair<int, int>;
constexpr auto is_odd = [](int const x) { return x % 2 != 0; };
// Validate that copy_if_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::copy_if_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::copy_if_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::copy_if(borrowed<false>{}, nullptr_to<int>, is_odd)),
static_assert(same_as<decltype(ranges::copy_if(borrowed<false>{}, nullptr_to<int>, is_odd)),
ranges::copy_if_result<ranges::dangling, int*>>);
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::copy_if(borrowed<true>{}, nullptr_to<int>, is_odd)), ranges::copy_if_result<int*, int*>>);
struct instantiator {
@ -82,7 +82,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = copy_if(wrapped_input, Write{output.data()}, is_odd, get_first);
STATIC_ASSERT(same_as<decltype(result), copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output.data() + 2);
assert(ranges::equal(output, expected));
@ -92,7 +92,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = copy_if(wrapped_input.begin(), wrapped_input.end(), Write{output.data()}, is_odd, get_first);
STATIC_ASSERT(same_as<decltype(result), copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output.data() + 2);
assert(ranges::equal(output, expected));
@ -102,7 +102,7 @@ struct instantiator {
int main() {
#ifndef _PREFAST_ // TRANSITION, GH-1030
STATIC_ASSERT((test_in_write<instantiator, P const, P>(), true));
static_assert((test_in_write<instantiator, P const, P>(), true));
#endif // TRANSITION, GH-1030
test_in_write<instantiator, P const, P>();
}

Просмотреть файл

@ -12,7 +12,7 @@
using namespace std;
// Validate that copy_n_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::copy_n_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::copy_n_result<int, double>, ranges::in_out_result<int, double>>);
struct instantiator {
static constexpr int input[3] = {13, 42, 1729};
@ -24,7 +24,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = copy_n(wrapped_input.begin(), 3, Write{output});
STATIC_ASSERT(same_as<decltype(result), copy_n_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), copy_n_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, input));
@ -32,6 +32,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in_write<instantiator, const int, int>(), true));
static_assert((test_in_write<instantiator, const int, int>(), true));
test_in_write<instantiator, const int, int>();
}

Просмотреть файл

@ -22,20 +22,20 @@ struct instantiator {
Read wrapped_input{input};
auto result = count(wrapped_input.begin(), wrapped_input.end(), 47, get_second);
STATIC_ASSERT(same_as<decltype(result), ranges::range_difference_t<Read>>);
static_assert(same_as<decltype(result), ranges::range_difference_t<Read>>);
assert(result == 2);
}
{ // Validate range overload
Read wrapped_input{input};
auto result = count(wrapped_input, 99, get_second);
STATIC_ASSERT(same_as<decltype(result), ranges::range_difference_t<Read>>);
static_assert(same_as<decltype(result), ranges::range_difference_t<Read>>);
assert(result == 3);
}
}
};
int main() {
STATIC_ASSERT((test_in<instantiator, P const>(), true));
static_assert((test_in<instantiator, P const>(), true));
test_in<instantiator, P const>();
}

Просмотреть файл

@ -25,20 +25,20 @@ struct instantiator {
Read wrapped_input{input};
auto result = count_if(wrapped_input.begin(), wrapped_input.end(), is_odd, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::range_difference_t<Read>>);
static_assert(same_as<decltype(result), ranges::range_difference_t<Read>>);
assert(result == 2);
}
{ // Validate range overload
Read wrapped_input{input};
auto result = count_if(wrapped_input, is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::range_difference_t<Read>>);
static_assert(same_as<decltype(result), ranges::range_difference_t<Read>>);
assert(result == 3);
}
}
};
int main() {
STATIC_ASSERT((test_in<instantiator, P const>(), true));
static_assert((test_in<instantiator, P const>(), true));
test_in<instantiator, P const>();
}

Просмотреть файл

@ -23,21 +23,21 @@ constexpr void smoke_test() {
{
// Validate sized ranges
auto result = equal(x, y, cmp, get_first, get_second);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!equal(x, y, cmp, get_first, get_first));
}
{
// Validate non-sized ranges
auto result = equal(basic_borrowed_range{x}, basic_borrowed_range{y}, cmp, get_first, get_second);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!equal(basic_borrowed_range{x}, basic_borrowed_range{y}, cmp, get_first, get_first));
}
{
// Validate sized iterator + sentinel pairs
auto result = equal(x.begin(), x.end(), y.begin(), y.end(), cmp, get_first, get_second);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
assert(!equal(x.begin(), x.end(), y.begin(), y.end(), cmp, get_first, get_first));
}
@ -47,7 +47,7 @@ constexpr void smoke_test() {
basic_borrowed_range wrapped_y{y};
auto result =
equal(wrapped_x.begin(), wrapped_x.end(), wrapped_y.begin(), wrapped_y.end(), cmp, get_first, get_second);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(result);
}
{
@ -87,7 +87,7 @@ constexpr void smoke_test() {
}
int main() {
STATIC_ASSERT((smoke_test(), true));
static_assert((smoke_test(), true));
smoke_test();
}

Просмотреть файл

@ -50,6 +50,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_out<instantiator, int>(), true));
static_assert((test_out<instantiator, int>(), true));
test_out<instantiator, int>();
}

Просмотреть файл

@ -55,6 +55,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_out<instantiator, int>(), true));
static_assert((test_out<instantiator, int>(), true));
test_out<instantiator, int>();
}

Просмотреть файл

@ -12,8 +12,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::find(borrowed<false>{}, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::find(borrowed<true>{}, 42)), int*>);
static_assert(same_as<decltype(ranges::find(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::find(borrowed<true>{}, 42)), int*>);
struct instantiator {
static constexpr P haystack[3] = {{0, 42}, {2, 42}, {4, 42}};
@ -26,26 +26,26 @@ struct instantiator {
{ // Validate range overload [found case]
Read wrapped_input{haystack};
auto result = find(wrapped_input, value, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == value);
}
{ // Validate iterator + sentinel overload [found case]
Read wrapped_input{haystack};
auto result = find(wrapped_input.begin(), wrapped_input.end(), value, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == value);
}
}
{ // Validate range overload [not found case]
Read wrapped_input{haystack};
auto result = find(wrapped_input, 42, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
{ // Validate iterator + sentinel overload [not found case]
Read wrapped_input{haystack};
auto result = find(wrapped_input.begin(), wrapped_input.end(), 42, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
{ // Validate memchr case
@ -67,6 +67,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -13,8 +13,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::find_end(borrowed<false>{}, span<const int>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::find_end(borrowed<true>{}, span<const int>{})), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::find_end(borrowed<false>{}, span<const int>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::find_end(borrowed<true>{}, span<const int>{})), ranges::subrange<int*>>);
struct instantiator {
static constexpr pair<int, int> pairs[] = {{0, 42}, {1, 42}, {0, 42}, {1, 42}, {0, 42}};
@ -34,7 +34,7 @@ struct instantiator {
Fwd1 haystack{pairs};
Fwd2 needle{good_needle};
const same_as<subrange<iterator_t<Fwd1>>> auto result = find_end(haystack, needle, pred, get_first);
STATIC_ASSERT(CanMemberSize<subrange<iterator_t<Fwd1>>> == sized_result);
static_assert(CanMemberSize<subrange<iterator_t<Fwd1>>> == sized_result);
if constexpr (sized_result) {
assert(result.size() == 2);
}
@ -80,7 +80,7 @@ struct instantiator {
template <ranges::forward_range Fwd1, ranges::forward_range Fwd2>
static void call() {
test<Fwd1, Fwd2>();
STATIC_ASSERT((test<Fwd1, Fwd2>(), true));
static_assert((test<Fwd1, Fwd2>(), true));
}
};
@ -117,9 +117,9 @@ int main() {
test_fwd_fwd<instantiator, const pair<int, int>, const int>();
#endif // ^^^ no workaround ^^^
STATIC_ASSERT(memcmp_test());
static_assert(memcmp_test());
memcmp_test();
STATIC_ASSERT((test_devcom_1559808(), true));
static_assert((test_devcom_1559808(), true));
test_devcom_1559808();
}

Просмотреть файл

@ -14,8 +14,8 @@ using P = pair<int, int>;
constexpr auto pred = [](const int x, const int y) { return x == y + 1; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::find_first_of(borrowed<false>{}, borrowed<true>{}, pred)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::find_first_of(borrowed<true>{}, borrowed<true>{}, pred)), int*>);
static_assert(same_as<decltype(ranges::find_first_of(borrowed<false>{}, borrowed<true>{}, pred)), ranges::dangling>);
static_assert(same_as<decltype(ranges::find_first_of(borrowed<true>{}, borrowed<true>{}, pred)), int*>);
struct instantiator {
static constexpr P haystack[7] = {{0, 42}, {1, 42}, {2, 42}, {3, 42}, {4, 42}, {5, 42}, {6, 42}};
@ -31,7 +31,7 @@ struct instantiator {
Read2 wrapped_needle{good_needle};
auto result = find_first_of(wrapped_haystack, wrapped_needle, pred, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read1>>);
static_assert(same_as<decltype(result), iterator_t<Read1>>);
assert(result.peek() == begin(haystack) + 2);
}
{ // Validate iterator + sentinel overload [found case]
@ -40,7 +40,7 @@ struct instantiator {
auto result = find_first_of(wrapped_haystack.begin(), wrapped_haystack.end(), wrapped_needle.begin(),
wrapped_needle.end(), pred, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read1>>);
static_assert(same_as<decltype(result), iterator_t<Read1>>);
assert(result.peek() == begin(haystack) + 2);
}
@ -49,7 +49,7 @@ struct instantiator {
Read2 wrapped_needle{bad_needle};
auto result = find_first_of(wrapped_haystack, wrapped_needle, pred, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read1>>);
static_assert(same_as<decltype(result), iterator_t<Read1>>);
assert(result == wrapped_haystack.end());
}
{
@ -59,7 +59,7 @@ struct instantiator {
auto result = find_first_of(wrapped_haystack.begin(), wrapped_haystack.end(), wrapped_needle.begin(),
wrapped_needle.end(), pred, get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read1>>);
static_assert(same_as<decltype(result), iterator_t<Read1>>);
assert(result == wrapped_haystack.end());
}
}
@ -67,7 +67,7 @@ struct instantiator {
#ifdef TEST_EVERYTHING
int main() {
STATIC_ASSERT((test_in_fwd<instantiator, const P, const int>(), true));
static_assert((test_in_fwd<instantiator, const P, const int>(), true));
test_in_fwd<instantiator, const P, const int>();
}
#else // ^^^ test all range combinations / test only interesting range combos vvv
@ -83,7 +83,7 @@ constexpr bool run_tests() {
}
int main() {
STATIC_ASSERT(run_tests());
static_assert(run_tests());
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -15,8 +15,8 @@ constexpr auto matches = [](const int val) { return val == 42; };
constexpr auto equals = [](auto x) { return [x](auto&& y) { return y == x; }; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::find_if(borrowed<false>{}, matches)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::find_if(borrowed<true>{}, matches)), int*>);
static_assert(same_as<decltype(ranges::find_if(borrowed<false>{}, matches)), ranges::dangling>);
static_assert(same_as<decltype(ranges::find_if(borrowed<true>{}, matches)), int*>);
struct instantiator {
static constexpr P haystack[3] = {{0, 42}, {2, 42}, {4, 42}};
@ -29,32 +29,32 @@ struct instantiator {
{ // Validate range overload [found case]
Read wrapped_input{haystack};
auto result = find_if(wrapped_input, equals(value), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == value);
}
{ // Validate iterator + sentinel overload [found case]
Read wrapped_input{haystack};
auto result = find_if(wrapped_input.begin(), wrapped_input.end(), equals(value), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == value);
}
}
{ // Validate range overload [not found case]
Read wrapped_input{haystack};
auto result = find_if(wrapped_input, equals(42), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
{ // Validate iterator + sentinel overload [not found case]
Read wrapped_input{haystack};
auto result = find_if(wrapped_input.begin(), wrapped_input.end(), equals(42), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
}
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -16,8 +16,8 @@ constexpr auto matches = [](const int val) { return val == 42; };
constexpr auto equals = [](auto x) { return [x](auto&& y) { return y == x; }; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::find_if_not(borrowed<false>{}, matches)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::find_if_not(borrowed<true>{}, matches)), int*>);
static_assert(same_as<decltype(ranges::find_if_not(borrowed<false>{}, matches)), ranges::dangling>);
static_assert(same_as<decltype(ranges::find_if_not(borrowed<true>{}, matches)), int*>);
struct instantiator {
template <ranges::input_range Read>
@ -30,13 +30,13 @@ struct instantiator {
{ // Validate range overload [found case]
Read wrapped_input{haystack};
auto result = find_if_not(wrapped_input, equals(0), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == 42);
}
{ // Validate iterator + sentinel overload [found case]
Read wrapped_input{haystack};
auto result = find_if_not(wrapped_input.begin(), wrapped_input.end(), equals(0), get_first);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result.peek()->first == 42);
}
value = 0;
@ -44,19 +44,19 @@ struct instantiator {
{ // Validate range overload [not found case]
Read wrapped_input{haystack};
auto result = find_if_not(wrapped_input, equals(13), get_second);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
{ // Validate iterator + sentinel overload [not found case]
Read wrapped_input{haystack};
auto result = find_if_not(wrapped_input.begin(), wrapped_input.end(), equals(13), get_second);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
}
}
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -15,12 +15,12 @@ using P = pair<int, int>;
constexpr auto incr = [](auto& y) { ++y; };
// Validate that for_each_result aliases in_fun_result
STATIC_ASSERT(same_as<ranges::for_each_result<int, double>, ranges::in_fun_result<int, double>>);
static_assert(same_as<ranges::for_each_result<int, double>, ranges::in_fun_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::for_each(borrowed<false>{}, identity{})),
static_assert(same_as<decltype(ranges::for_each(borrowed<false>{}, identity{})),
ranges::for_each_result<ranges::dangling, identity>>);
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::for_each(borrowed<true>{}, identity{})), ranges::for_each_result<int*, identity>>);
struct instantiator {
@ -35,7 +35,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = for_each(wrapped_input.begin(), wrapped_input.end(), incr, get_first);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), for_each_result<iterator_t<ReadWrite>, remove_const_t<decltype(incr)>>>);
assert(result.in == wrapped_input.end());
assert(ranges::equal(expected, input));
@ -49,7 +49,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = for_each(wrapped_input, incr, get_first);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), for_each_result<iterator_t<ReadWrite>, remove_const_t<decltype(incr)>>>);
assert(result.in == wrapped_input.end());
assert(ranges::equal(expected, input));
@ -62,6 +62,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, P>(), true));
static_assert((test_in<instantiator, P>(), true));
test_in<instantiator, P>();
}

Просмотреть файл

@ -14,7 +14,7 @@ using P = pair<int, int>;
constexpr auto incr = [](auto& y) { ++y; };
// Validate that for_each_n_result aliases in_fun_result
STATIC_ASSERT(same_as<ranges::for_each_n_result<int, double>, ranges::in_fun_result<int, double>>);
static_assert(same_as<ranges::for_each_n_result<int, double>, ranges::in_fun_result<int, double>>);
struct instantiator {
static constexpr P expected[3] = {{1, 42}, {3, 42}, {5, 42}};
@ -25,7 +25,7 @@ struct instantiator {
P input[3] = {{0, 42}, {2, 42}, {4, 42}};
auto result = for_each_n(ReadWrite{input}, distance(input), incr, get_first);
STATIC_ASSERT(same_as<decltype(result), for_each_n_result<ReadWrite, remove_const_t<decltype(incr)>>>);
static_assert(same_as<decltype(result), for_each_n_result<ReadWrite, remove_const_t<decltype(incr)>>>);
assert(result.in.peek() == end(input));
assert(ranges::equal(expected, input));
@ -36,6 +36,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_read<instantiator, P>(), true));
static_assert((test_read<instantiator, P>(), true));
test_read<instantiator, P>();
}

Просмотреть файл

@ -13,8 +13,8 @@ using namespace std;
constexpr auto iota_gen = [val = 0]() mutable { return val++; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::generate(borrowed<false>{}, iota_gen)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::generate(borrowed<true>{}, iota_gen)), int*>);
static_assert(same_as<decltype(ranges::generate(borrowed<false>{}, iota_gen)), ranges::dangling>);
static_assert(same_as<decltype(ranges::generate(borrowed<true>{}, iota_gen)), int*>);
struct instantiator {
template <ranges::output_range<const int&> Out>
@ -25,7 +25,7 @@ struct instantiator {
int output[] = {13, 42, 1367};
Out out_wrapper{output};
auto result = generate(out_wrapper, iota_gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Out>>);
static_assert(same_as<decltype(result), iterator_t<Out>>);
assert(result == out_wrapper.end());
for (int i = 0; i < 3; ++i) {
assert(i == output[i]);
@ -35,7 +35,7 @@ struct instantiator {
int output[] = {13, 42, 1367};
Out out_wrapper{output};
auto result = generate(out_wrapper.begin(), out_wrapper.end(), iota_gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Out>>);
static_assert(same_as<decltype(result), iterator_t<Out>>);
assert(result == out_wrapper.end());
for (int i = 0; i < 3; ++i) {
assert(i == output[i]);
@ -45,6 +45,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_out<instantiator, int>(), true));
static_assert((test_out<instantiator, int>(), true));
test_out<instantiator, int>();
}

Просмотреть файл

@ -21,7 +21,7 @@ struct instantiator {
int output[] = {13, 42, 1367};
Out out_wrapper{output};
auto result = generate_n(out_wrapper.begin(), ranges::distance(output), iota_gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Out>>);
static_assert(same_as<decltype(result), iterator_t<Out>>);
assert(result == out_wrapper.end());
for (int i = 0; i < 3; ++i) {
assert(i == output[i]);
@ -33,14 +33,14 @@ struct instantiator {
{
Out out_wrapper{output};
auto result = generate_n(out_wrapper.begin(), 0, iota_gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Out>>);
static_assert(same_as<decltype(result), iterator_t<Out>>);
assert(result.peek() == output);
assert(equal(output, expected_output));
}
{
Out out_wrapper{output};
auto result = generate_n(out_wrapper.begin(), -1, iota_gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Out>>);
static_assert(same_as<decltype(result), iterator_t<Out>>);
assert(result.peek() == output);
assert(equal(output, expected_output));
}
@ -48,6 +48,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_out<instantiator, int>(), true));
static_assert((test_out<instantiator, int>(), true));
test_out<instantiator, int>();
}

Просмотреть файл

@ -19,16 +19,16 @@ using namespace std;
#define ASSERT(...) assert((__VA_ARGS__))
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::push_heap(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::push_heap(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::pop_heap(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::pop_heap(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::make_heap(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::make_heap(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::sort_heap(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::sort_heap(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::is_heap_until(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::is_heap_until(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::push_heap(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::push_heap(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::pop_heap(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::pop_heap(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::make_heap(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::make_heap(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::sort_heap(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::sort_heap(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::is_heap_until(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::is_heap_until(borrowed<true>{})), int*>);
using P = pair<int, int>;
@ -144,7 +144,7 @@ struct push_and_pop_heap_test {
P{-1298559576, 8},
P{-1260655766, 9},
};
STATIC_ASSERT(ranges::is_heap(initial_values, ranges::less{}, get_first));
static_assert(ranges::is_heap(initial_values, ranges::less{}, get_first));
static constexpr array expectedPushed = {
P{1668617627, 0},
@ -158,7 +158,7 @@ struct push_and_pop_heap_test {
P{-1298559576, 8},
P{-1200257975, 4},
};
STATIC_ASSERT(ranges::is_heap(expectedPushed, ranges::less{}, get_first));
static_assert(ranges::is_heap(expectedPushed, ranges::less{}, get_first));
static constexpr array expectedPopped = {
P{1429106719, 1},
@ -172,7 +172,7 @@ struct push_and_pop_heap_test {
P{-1298559576, 8},
P{1668617627, 0},
};
STATIC_ASSERT(ranges::is_heap(expectedPopped.begin(), expectedPopped.end() - 1, ranges::less{}, get_first));
static_assert(ranges::is_heap(expectedPopped.begin(), expectedPopped.end() - 1, ranges::less{}, get_first));
template <ranges::random_access_range Range>
static constexpr void call() {
@ -206,15 +206,15 @@ struct push_and_pop_heap_test {
};
int main() {
STATIC_ASSERT((test_random<empty_ranges, P>(), true));
static_assert((test_random<empty_ranges, P>(), true));
test_random<empty_ranges, P>();
STATIC_ASSERT((test_random<is_heap_test, P>(), true));
static_assert((test_random<is_heap_test, P>(), true));
test_random<is_heap_test, P>();
STATIC_ASSERT((test_random<make_and_sort_heap_test, P>(), true));
static_assert((test_random<make_and_sort_heap_test, P>(), true));
test_random<make_and_sort_heap_test, P>();
STATIC_ASSERT((test_random<push_and_pop_heap_test, P>(), true));
static_assert((test_random<push_and_pop_heap_test, P>(), true));
test_random<push_and_pop_heap_test, P>();
}

Просмотреть файл

@ -63,7 +63,7 @@ struct instantiator {
#ifdef TEST_EVERYTHING
int main() {
STATIC_ASSERT((test_in_in<instantiator, const P, const int>(), true));
static_assert((test_in_in<instantiator, const P, const int>(), true));
test_in_in<instantiator, const P, const int>();
}
#else // ^^^ test all permutations of range properties / test only interesting permutations vvv
@ -99,7 +99,7 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -13,8 +13,8 @@
using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::inplace_merge(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::inplace_merge(borrowed<true>{}, nullptr_to<int>)), int*>);
static_assert(same_as<decltype(ranges::inplace_merge(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
static_assert(same_as<decltype(ranges::inplace_merge(borrowed<true>{}, nullptr_to<int>)), int*>);
struct instantiator {
static constexpr P expected[] = {P{0, 1}, P{0, 5}, P{4, 2}, P{4, 6}, P{6, 7}, P{7, 3}, P{8, 4}, P{9, 8}, P{10, 9}};

Просмотреть файл

@ -197,7 +197,7 @@ constexpr bool run_tests() {
}
int main() {
STATIC_ASSERT(run_tests());
static_assert(run_tests());
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -15,8 +15,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::is_sorted_until(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::is_sorted_until(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::is_sorted_until(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::is_sorted_until(borrowed<true>{})), int*>);
using P = pair<int, int>;
@ -70,9 +70,9 @@ struct iterator_overloads {
};
int main() {
STATIC_ASSERT((test_fwd<range_overloads, const P>(), true));
static_assert((test_fwd<range_overloads, const P>(), true));
test_fwd<range_overloads, const P>();
STATIC_ASSERT((test_fwd<iterator_overloads, const P>(), true));
static_assert((test_fwd<iterator_overloads, const P>(), true));
test_fwd<iterator_overloads, const P>();
}

Просмотреть файл

@ -254,7 +254,7 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -14,16 +14,16 @@ using namespace std;
using P = pair<int, int>;
// Validate that merge_result aliases in_in_out_result
STATIC_ASSERT(same_as<ranges::merge_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
static_assert(same_as<ranges::merge_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::merge(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::merge(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>)),
ranges::merge_result<ranges::dangling, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::merge(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::merge(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>)),
ranges::merge_result<ranges::dangling, int*, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::merge(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::merge(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>)),
ranges::merge_result<int*, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::merge(borrowed<true>{}, borrowed<true>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::merge(borrowed<true>{}, borrowed<true>{}, nullptr_to<int>)),
ranges::merge_result<int*, int*, int*>>);
struct instantiator {
@ -150,6 +150,6 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}

Просмотреть файл

@ -23,19 +23,19 @@ using namespace std;
#define ASSERT(...) assert((__VA_ARGS__))
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::min_element(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::min_element(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::min_element(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::min_element(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::max_element(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::max_element(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::max_element(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::max_element(borrowed<true>{})), int*>);
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::minmax_element(borrowed<false>{})), ranges::minmax_element_result<ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::minmax_element(borrowed<true>{})), ranges::minmax_element_result<int*>>);
static_assert(same_as<decltype(ranges::minmax_element(borrowed<true>{})), ranges::minmax_element_result<int*>>);
// Validate that minmax_result and minmax_element_result alias min_max_result
STATIC_ASSERT(same_as<ranges::minmax_result<int>, ranges::min_max_result<int>>);
STATIC_ASSERT(same_as<ranges::minmax_element_result<int>, ranges::min_max_result<int>>);
static_assert(same_as<ranges::minmax_result<int>, ranges::min_max_result<int>>);
static_assert(same_as<ranges::minmax_element_result<int>, ranges::min_max_result<int>>);
using P = pair<int, int>;
@ -55,13 +55,13 @@ struct mm_element_empty {
{
auto result = ranges::minmax_element(range, ranges::less{}, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::minmax_element_result<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), ranges::minmax_element_result<ranges::iterator_t<Fwd>>>);
ASSERT(result.min == ranges::end(range));
ASSERT(result.max == ranges::end(range));
}
{
auto result = ranges::minmax_element(ranges::begin(range), ranges::end(range), ranges::less{}, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::minmax_element_result<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), ranges::minmax_element_result<ranges::iterator_t<Fwd>>>);
ASSERT(result.min == ranges::end(range));
ASSERT(result.max == ranges::end(range));
}
@ -171,7 +171,7 @@ struct mm {
{
auto result = ranges::minmax(In{elements}, ranges::less{}, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::minmax_result<P>>);
static_assert(same_as<decltype(result), ranges::minmax_result<P>>);
ASSERT(result.min == P{0, 42});
ASSERT(result.max == (i == 7 ? P{5, 6} : P{5, 7}));
}
@ -186,7 +186,7 @@ struct mm {
{
auto result = ranges::minmax(In{elements}, ranges::less{}, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::minmax_result<P>>);
static_assert(same_as<decltype(result), ranges::minmax_result<P>>);
ASSERT(result.min == P{0, 42});
ASSERT(result.max == (j == 7 ? (i == 6 ? P{5, 5} : P{5, 6}) : P{5, 7}));
}
@ -292,7 +292,7 @@ constexpr void init_list_constexpr_tests() {
== P{5, 0});
auto result = ranges::minmax(
{P{5, 0}, P{5, 1}, P{5, 2}, P{5, 3}, P{5, 4}, P{5, 5}, P{5, 6}, P{5, 7}}, ranges::less{}, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::minmax_result<P>>);
static_assert(same_as<decltype(result), ranges::minmax_result<P>>);
ASSERT(result.min == P{5, 0});
ASSERT(result.max == P{5, 7});
}
@ -422,19 +422,19 @@ void test_gh_2900() {
}
int main() {
STATIC_ASSERT((nonrange_tests(), true));
static_assert((nonrange_tests(), true));
nonrange_tests();
STATIC_ASSERT((init_list_constexpr_tests(), true));
static_assert((init_list_constexpr_tests(), true));
init_list_constexpr_tests();
STATIC_ASSERT((test_fwd<mm_element_empty, const P>(), true));
static_assert((test_fwd<mm_element_empty, const P>(), true));
test_fwd<mm_element_empty, const P>();
STATIC_ASSERT((mm_element_constexpr_tests(), true));
static_assert((mm_element_constexpr_tests(), true));
test_fwd<mm_element, const P>();
STATIC_ASSERT((mm_constexpr_tests(), true));
static_assert((mm_constexpr_tests(), true));
test_in<mm, const P>();
test_gh_1893();

Просмотреть файл

@ -21,21 +21,21 @@ constexpr void smoke_test() {
std::array<std::pair<long, long>, 3> const y = {{{13, 0}, {13, 2}, {13, 5}}};
// Validate that mismatch_result aliases in_in_result
STATIC_ASSERT(same_as<mismatch_result<int, double>, ranges::in_in_result<int, double>>);
static_assert(same_as<mismatch_result<int, double>, ranges::in_in_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(
static_assert(
same_as<decltype(mismatch(borrowed<false>{}, borrowed<false>{})), mismatch_result<dangling, dangling>>);
STATIC_ASSERT(same_as<decltype(mismatch(borrowed<false>{}, borrowed<true>{})), mismatch_result<dangling, int*>>);
STATIC_ASSERT(same_as<decltype(mismatch(borrowed<true>{}, borrowed<false>{})), mismatch_result<int*, dangling>>);
STATIC_ASSERT(same_as<decltype(mismatch(borrowed<true>{}, borrowed<true>{})), mismatch_result<int*, int*>>);
static_assert(same_as<decltype(mismatch(borrowed<false>{}, borrowed<true>{})), mismatch_result<dangling, int*>>);
static_assert(same_as<decltype(mismatch(borrowed<true>{}, borrowed<false>{})), mismatch_result<int*, dangling>>);
static_assert(same_as<decltype(mismatch(borrowed<true>{}, borrowed<true>{})), mismatch_result<int*, int*>>);
{
// Validate sized ranges
auto result = mismatch(x, y, equal_to{}, get_first, get_second);
using I1 = iterator_t<R const>;
using I2 = std::array<std::pair<long, long>, 3>::const_iterator;
STATIC_ASSERT(same_as<decltype(result), mismatch_result<I1, I2>>);
static_assert(same_as<decltype(result), mismatch_result<I1, I2>>);
assert((*result.in1 == P{4, 42}));
assert((*result.in2 == std::pair<long, long>{13, 5}));
}
@ -44,7 +44,7 @@ constexpr void smoke_test() {
auto result = mismatch(basic_borrowed_range{x}, basic_borrowed_range{y}, equal_to{}, get_first, get_second);
using I1 = iterator_t<basic_borrowed_range<P const>>;
using I2 = iterator_t<basic_borrowed_range<std::pair<long, long> const>>;
STATIC_ASSERT(same_as<decltype(result), mismatch_result<I1, I2>>);
static_assert(same_as<decltype(result), mismatch_result<I1, I2>>);
assert((*result.in1 == P{4, 42}));
assert((*result.in2 == std::pair<long, long>{13, 5}));
}
@ -53,7 +53,7 @@ constexpr void smoke_test() {
auto result = mismatch(x.begin(), x.end(), y.begin(), y.end(), equal_to{}, get_first, get_second);
using I1 = iterator_t<R const>;
using I2 = std::array<std::pair<long, long>, 3>::const_iterator;
STATIC_ASSERT(same_as<decltype(result), mismatch_result<I1, I2>>);
static_assert(same_as<decltype(result), mismatch_result<I1, I2>>);
assert((*result.in1 == P{4, 42}));
assert((*result.in2 == std::pair<long, long>{13, 5}));
}
@ -65,14 +65,14 @@ constexpr void smoke_test() {
wrapped_x.begin(), wrapped_x.end(), wrapped_y.begin(), wrapped_y.end(), equal_to{}, get_first, get_second);
using I1 = iterator_t<decltype(wrapped_x)>;
using I2 = iterator_t<decltype(wrapped_y)>;
STATIC_ASSERT(same_as<decltype(result), mismatch_result<I1, I2>>);
static_assert(same_as<decltype(result), mismatch_result<I1, I2>>);
assert((*result.in1 == P{4, 42}));
assert((*result.in2 == std::pair<long, long>{13, 5}));
}
}
int main() {
STATIC_ASSERT((smoke_test(), true));
static_assert((smoke_test(), true));
smoke_test();
}

Просмотреть файл

@ -24,12 +24,12 @@ struct int_wrapper {
};
// Validate that move_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::move_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::move_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::move(borrowed<false>{}, nullptr_to<int>)), ranges::move_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::move(borrowed<true>{}, nullptr_to<int>)), ranges::move_result<int*, int*>>);
static_assert(same_as<decltype(ranges::move(borrowed<true>{}, nullptr_to<int>)), ranges::move_result<int*, int*>>);
struct instantiator {
static constexpr int_wrapper expected_output[3] = {13, 55, 12345};
@ -44,7 +44,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = move(wrapped_input, Write{output});
STATIC_ASSERT(same_as<decltype(result), move_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), move_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected_output));
@ -56,7 +56,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = move(wrapped_input.begin(), wrapped_input.end(), Write{output});
STATIC_ASSERT(same_as<decltype(result), move_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), move_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected_output));
@ -67,7 +67,7 @@ struct instantiator {
int main() {
#ifndef _PREFAST_ // TRANSITION, GH-1030
STATIC_ASSERT((test_in_write<instantiator, int_wrapper, int_wrapper>(), true));
static_assert((test_in_write<instantiator, int_wrapper, int_wrapper>(), true));
#endif // TRANSITION, GH-1030
test_in_write<instantiator, int_wrapper, int_wrapper>();
}

Просмотреть файл

@ -33,12 +33,12 @@ constexpr auto get_int_wrapper_val = &int_wrapper::val;
#endif // ^^^ no workaround ^^^
// Validate that move_backward_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::move_backward_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::move_backward_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::move_backward(borrowed<false>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::move_backward(borrowed<false>{}, nullptr_to<int>)),
ranges::move_backward_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::move_backward(borrowed<true>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::move_backward(borrowed<true>{}, nullptr_to<int>)),
ranges::move_backward_result<int*, int*>>);
struct instantiator {
@ -137,9 +137,9 @@ constexpr void test_memmove() {
}
int main() {
STATIC_ASSERT((test_bidi_bidi<instantiator, int_wrapper, int_wrapper>(), true));
static_assert((test_bidi_bidi<instantiator, int_wrapper, int_wrapper>(), true));
test_bidi_bidi<instantiator, int_wrapper, int_wrapper>();
STATIC_ASSERT((test_memmove(), true));
static_assert((test_memmove(), true));
test_memmove();
}

Просмотреть файл

@ -27,7 +27,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = none_of(wrapped_input1.begin(), wrapped_input1.end(), is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(!result);
assert(none_of(wrapped_input2.begin(), wrapped_input2.end(), is_even, get_second));
assert(!none_of(wrapped_input3.begin(), wrapped_input3.end(), is_odd, get_first));
@ -40,7 +40,7 @@ struct instantiator {
Read wrapped_input4{input};
auto result = none_of(wrapped_input1, is_even, get_first);
STATIC_ASSERT(same_as<decltype(result), bool>);
static_assert(same_as<decltype(result), bool>);
assert(!result);
assert(none_of(wrapped_input2, is_even, get_second));
assert(!none_of(wrapped_input3, is_odd, get_first));
@ -50,6 +50,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, const P>(), true));
static_assert((test_in<instantiator, const P>(), true));
test_in<instantiator, const P>();
}

Просмотреть файл

@ -13,8 +13,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::nth_element(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::nth_element(borrowed<true>{}, nullptr_to<int>)), int*>);
static_assert(same_as<decltype(ranges::nth_element(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
static_assert(same_as<decltype(ranges::nth_element(borrowed<true>{}, nullptr_to<int>)), int*>);
using P = pair<int, int>;
@ -72,6 +72,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_random<instantiator, P>(), true));
static_assert((test_random<instantiator, P>(), true));
test_random<instantiator, P>();
}

Просмотреть файл

@ -13,8 +13,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::partial_sort(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::partial_sort(borrowed<true>{}, nullptr_to<int>)), int*>);
static_assert(same_as<decltype(ranges::partial_sort(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
static_assert(same_as<decltype(ranges::partial_sort(borrowed<true>{}, nullptr_to<int>)), int*>);
struct instantiator {
static constexpr P sorted[] = {{0, 16}, {1, 12}, {2, 17}, {3, 13}, {4, 15}, {5, 11}, {6, 14}, {7, 10}};
@ -49,6 +49,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_random<instantiator, P>(), true));
static_assert((test_random<instantiator, P>(), true));
test_random<instantiator, P>();
}

Просмотреть файл

@ -15,16 +15,16 @@ using namespace std;
using P = pair<int, int>;
// Validate that partial_sort_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::partial_sort_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::partial_sort_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::partial_sort_copy(borrowed<false>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::partial_sort_copy(borrowed<false>{}, borrowed<false>{})),
ranges::partial_sort_copy_result<ranges::dangling, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::partial_sort_copy(borrowed<false>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::partial_sort_copy(borrowed<false>{}, borrowed<true>{})),
ranges::partial_sort_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::partial_sort_copy(borrowed<true>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::partial_sort_copy(borrowed<true>{}, borrowed<false>{})),
ranges::partial_sort_copy_result<int*, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::partial_sort_copy(borrowed<true>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::partial_sort_copy(borrowed<true>{}, borrowed<true>{})),
ranges::partial_sort_copy_result<int*, int*>>);
constexpr P source[] = {{5, 11}, {1, 12}, {3, 13}, {4, 15}, {0, 16}, {2, 17}};
@ -135,7 +135,7 @@ struct weird_pair : pair<string, string> {
};
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
{

Просмотреть файл

@ -23,8 +23,8 @@ using P = pair<int, int>;
constexpr auto is_even = [](int i) { return i % 2 == 0; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::partition(borrowed<false>{}, is_even)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::partition(borrowed<true>{}, is_even)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::partition(borrowed<false>{}, is_even)), ranges::dangling>);
static_assert(same_as<decltype(ranges::partition(borrowed<true>{}, is_even)), ranges::subrange<int*>>);
struct empty_test {
template <ranges::input_range Range>
@ -112,9 +112,9 @@ struct partition_test {
};
int main() {
STATIC_ASSERT((test_in<empty_test, P>(), true));
static_assert((test_in<empty_test, P>(), true));
test_in<empty_test, P>();
STATIC_ASSERT((test_in<partition_test, P>(), true));
static_assert((test_in<partition_test, P>(), true));
test_in<partition_test, P>();
}

Просмотреть файл

@ -21,13 +21,13 @@ using P = pair<int, int>;
constexpr auto is_even = [](int i) { return i % 2 == 0; };
// Validate that partition_copy_result aliases in_out_out_result
STATIC_ASSERT(
static_assert(
same_as<ranges::partition_copy_result<int, double, void*>, ranges::in_out_out_result<int, double, void*>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::partition_copy(borrowed<false>{}, nullptr_to<int>, nullptr_to<long>, is_even)),
static_assert(same_as<decltype(ranges::partition_copy(borrowed<false>{}, nullptr_to<int>, nullptr_to<long>, is_even)),
ranges::partition_copy_result<ranges::dangling, int*, long*>>);
STATIC_ASSERT(same_as<decltype(ranges::partition_copy(borrowed<true>{}, nullptr_to<int>, nullptr_to<long>, is_even)),
static_assert(same_as<decltype(ranges::partition_copy(borrowed<true>{}, nullptr_to<int>, nullptr_to<long>, is_even)),
ranges::partition_copy_result<int*, int*, long*>>);
struct empty_test {
@ -124,9 +124,9 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests<empty_test, const P>(), true));
static_assert((run_tests<empty_test, const P>(), true));
run_tests<empty_test, const P>();
STATIC_ASSERT((run_tests<partition_copy_test, const P>(), true));
static_assert((run_tests<partition_copy_test, const P>(), true));
run_tests<partition_copy_test, const P>();
}

Просмотреть файл

@ -21,8 +21,8 @@ using P = pair<int, int>;
constexpr auto is_even = [](int i) { return i % 2 == 0; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::partition_point(borrowed<false>{}, is_even)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::partition_point(borrowed<true>{}, is_even)), int*>);
static_assert(same_as<decltype(ranges::partition_point(borrowed<false>{}, is_even)), ranges::dangling>);
static_assert(same_as<decltype(ranges::partition_point(borrowed<true>{}, is_even)), int*>);
struct empty_test {
template <ranges::forward_range Range>
@ -56,9 +56,9 @@ struct partition_point_test {
};
int main() {
STATIC_ASSERT((test_fwd<empty_test, P>(), true));
static_assert((test_fwd<empty_test, P>(), true));
test_fwd<empty_test, P>();
STATIC_ASSERT((test_fwd<partition_point_test, const int>(), true));
static_assert((test_fwd<partition_point_test, const int>(), true));
test_fwd<partition_point_test, const int>();
}

Просмотреть файл

@ -16,16 +16,16 @@ using namespace std;
#pragma warning(disable : 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed
// Validate that (next|prev)_permutation_result alias in_found_result
STATIC_ASSERT(same_as<ranges::next_permutation_result<int>, ranges::in_found_result<int>>);
STATIC_ASSERT(same_as<ranges::prev_permutation_result<int>, ranges::in_found_result<int>>);
static_assert(same_as<ranges::next_permutation_result<int>, ranges::in_found_result<int>>);
static_assert(same_as<ranges::prev_permutation_result<int>, ranges::in_found_result<int>>);
// Validate dangling story
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::next_permutation(borrowed<false>{})), ranges::next_permutation_result<ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::next_permutation(borrowed<true>{})), ranges::next_permutation_result<int*>>);
STATIC_ASSERT(
static_assert(same_as<decltype(ranges::next_permutation(borrowed<true>{})), ranges::next_permutation_result<int*>>);
static_assert(
same_as<decltype(ranges::prev_permutation(borrowed<false>{})), ranges::prev_permutation_result<ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::prev_permutation(borrowed<true>{})), ranges::prev_permutation_result<int*>>);
static_assert(same_as<decltype(ranges::prev_permutation(borrowed<true>{})), ranges::prev_permutation_result<int*>>);
constexpr int perm1[][1] = {{0}};
constexpr int perm4[][4] = {{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 2, 1, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, {0, 3, 2, 1},
@ -237,21 +237,21 @@ struct empty_range_test {
};
int main() {
STATIC_ASSERT((test_bidi<empty_range_test, int_wrapper>(), true));
static_assert((test_bidi<empty_range_test, int_wrapper>(), true));
test_bidi<empty_range_test, int_wrapper>();
STATIC_ASSERT((test_bidi<next_perm_instantiator<perm1>, int_wrapper>(), true));
STATIC_ASSERT((test_bidi<next_perm_instantiator<perm4>, int_wrapper>(), true));
STATIC_ASSERT((test_bidi<next_perm_instantiator<perm8>, int_wrapper>(), true));
static_assert((test_bidi<next_perm_instantiator<perm1>, int_wrapper>(), true));
static_assert((test_bidi<next_perm_instantiator<perm4>, int_wrapper>(), true));
static_assert((test_bidi<next_perm_instantiator<perm8>, int_wrapper>(), true));
test_bidi<next_perm_instantiator<perm1>, int_wrapper>();
test_bidi<next_perm_instantiator<perm4>, int_wrapper>();
test_bidi<next_perm_instantiator<perm5>, int_wrapper>();
test_bidi<next_perm_instantiator<perm6>, int_wrapper>();
test_bidi<next_perm_instantiator<perm8>, int_wrapper>();
STATIC_ASSERT((test_bidi<prev_perm_instantiator<perm1>, int_wrapper>(), true));
STATIC_ASSERT((test_bidi<prev_perm_instantiator<perm4>, int_wrapper>(), true));
STATIC_ASSERT((test_bidi<prev_perm_instantiator<perm8>, int_wrapper>(), true));
static_assert((test_bidi<prev_perm_instantiator<perm1>, int_wrapper>(), true));
static_assert((test_bidi<prev_perm_instantiator<perm4>, int_wrapper>(), true));
static_assert((test_bidi<prev_perm_instantiator<perm8>, int_wrapper>(), true));
test_bidi<prev_perm_instantiator<perm1>, int_wrapper>();
test_bidi<prev_perm_instantiator<perm4>, int_wrapper>();
test_bidi<prev_perm_instantiator<perm5>, int_wrapper>();

Просмотреть файл

@ -13,8 +13,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::remove(borrowed<false>{}, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::remove(borrowed<true>{}, 42)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::remove(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::remove(borrowed<true>{}, 42)), ranges::subrange<int*>>);
struct instantiator {
static constexpr P expected[3] = {{0, 99}, {2, 99}, {4, 99}};
@ -34,7 +34,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove(wrapped_input.begin(), wrapped_input.end(), 47, projection);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<Read>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<Read>>>);
assert(result.begin() == next(wrapped_input.begin(), 3));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<3>()));
@ -48,7 +48,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove(wrapped_input, 47, projection);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<Read>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<Read>>>);
assert(result.begin() == next(wrapped_input.begin(), 3));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<3>()));
@ -58,6 +58,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_fwd<instantiator, P>(), true));
static_assert((test_fwd<instantiator, P>(), true));
test_fwd<instantiator, P>();
}

Просмотреть файл

@ -12,12 +12,12 @@ using namespace std;
using P = pair<int, int>;
// Validate that remove_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::remove_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::remove_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::remove_copy(borrowed<false>{}, static_cast<int*>(nullptr), 42)),
static_assert(same_as<decltype(ranges::remove_copy(borrowed<false>{}, static_cast<int*>(nullptr), 42)),
ranges::remove_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::remove_copy(borrowed<true>{}, static_cast<int*>(nullptr), 42)),
static_assert(same_as<decltype(ranges::remove_copy(borrowed<true>{}, static_cast<int*>(nullptr), 42)),
ranges::remove_copy_result<int*, int*>>);
struct counted_projection {
@ -50,7 +50,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove_copy(wrapped_input.begin(), wrapped_input.end(), Write{output}, 47, projection);
STATIC_ASSERT(same_as<decltype(result), remove_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), remove_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected));
@ -64,7 +64,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove_copy(wrapped_input, Write{output}, 47, projection);
STATIC_ASSERT(same_as<decltype(result), remove_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), remove_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected));
@ -83,7 +83,7 @@ using test_range = test::range<Category, const P, IsSized,
int main() {
#ifdef TEST_EVERYTHING
STATIC_ASSERT((test_in_write<instantiator, const P, P>(), true));
static_assert((test_in_write<instantiator, const P, P>(), true));
test_in_write<instantiator, const P, P>();
#else // ^^^ test all input range permutations / test only "interesting" permutations vvv
// The algorithm is insensitive to _every_ range property; it's simply a conditional copy.

Просмотреть файл

@ -14,12 +14,12 @@ using P = pair<int, int>;
constexpr auto matches = [](const int val) { return val == 47; };
// Validate that remove_copy_if_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::remove_copy_if_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::remove_copy_if_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::remove_copy_if(borrowed<false>{}, static_cast<int*>(nullptr), matches)),
static_assert(same_as<decltype(ranges::remove_copy_if(borrowed<false>{}, static_cast<int*>(nullptr), matches)),
ranges::remove_copy_if_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::remove_copy_if(borrowed<true>{}, static_cast<int*>(nullptr), matches)),
static_assert(same_as<decltype(ranges::remove_copy_if(borrowed<true>{}, static_cast<int*>(nullptr), matches)),
ranges::remove_copy_if_result<int*, int*>>);
struct counted_projection {
@ -52,7 +52,7 @@ struct instantiator {
Read wrapped_input{input};
auto result =
remove_copy_if(wrapped_input.begin(), wrapped_input.end(), Write{output}, matches, projection);
STATIC_ASSERT(same_as<decltype(result), remove_copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), remove_copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected));
@ -65,7 +65,7 @@ struct instantiator {
P output[3] = {{-1, -1}, {-1, -1}, {-1, -1}};
Read wrapped_input{input};
auto result = remove_copy_if(wrapped_input, Write{output}, matches, projection);
STATIC_ASSERT(same_as<decltype(result), remove_copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), remove_copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(equal(output, expected));
@ -84,7 +84,7 @@ using test_range = test::range<Category, const P, IsSized,
int main() {
#ifdef TEST_EVERYTHING
STATIC_ASSERT((test_in_write<instantiator, const P, P>(), true));
static_assert((test_in_write<instantiator, const P, P>(), true));
test_in_write<instantiator, const P, P>();
#else // ^^^ test all input range permutations / test only "interesting" permutations vvv
// The algorithm is insensitive to _every_ range property; it's simply a conditional copy.

Просмотреть файл

@ -15,8 +15,8 @@ using P = pair<int, int>;
constexpr auto matches = [](const int val) { return val == 47; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::remove_if(borrowed<false>{}, matches)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::remove_if(borrowed<true>{}, matches)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::remove_if(borrowed<false>{}, matches)), ranges::dangling>);
static_assert(same_as<decltype(ranges::remove_if(borrowed<true>{}, matches)), ranges::subrange<int*>>);
struct instantiator {
static constexpr P expected[3] = {{0, 99}, {2, 99}, {4, 99}};
@ -36,7 +36,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove_if(wrapped_input.begin(), wrapped_input.end(), matches, projection);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<Read>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<Read>>>);
assert(result.begin() == next(wrapped_input.begin(), 3));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<3>()));
@ -50,7 +50,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = remove_if(wrapped_input, matches, projection);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<Read>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<Read>>>);
assert(result.begin() == next(wrapped_input.begin(), 3));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<3>()));
@ -60,6 +60,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_fwd<instantiator, P>(), true));
static_assert((test_fwd<instantiator, P>(), true));
test_fwd<instantiator, P>();
}

Просмотреть файл

@ -12,8 +12,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::replace(borrowed<false>{}, 42, 5)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::replace(borrowed<true>{}, 42, 5)), int*>);
static_assert(same_as<decltype(ranges::replace(borrowed<false>{}, 42, 5)), ranges::dangling>);
static_assert(same_as<decltype(ranges::replace(borrowed<true>{}, 42, 5)), int*>);
struct instantiator {
static constexpr P output[5] = {{0, 99}, {47, 1}, {2, 99}, {47, 1}, {4, 99}};
@ -26,7 +26,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace(wrapped_input.begin(), wrapped_input.end(), 47, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
assert(ranges::equal(output, input));
}
@ -35,7 +35,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace(wrapped_input, 47, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), iterator_t<Read>>);
static_assert(same_as<decltype(result), iterator_t<Read>>);
assert(result == wrapped_input.end());
assert(ranges::equal(output, input));
}
@ -43,6 +43,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, P>(), true));
static_assert((test_in<instantiator, P>(), true));
test_in<instantiator, P>();
}

Просмотреть файл

@ -12,12 +12,12 @@ using namespace std;
using P = pair<int, int>;
// Validate that replace_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::replace_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::replace_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::replace_copy(borrowed<false>{}, nullptr_to<int>, 42, 5)),
static_assert(same_as<decltype(ranges::replace_copy(borrowed<false>{}, nullptr_to<int>, 42, 5)),
ranges::replace_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::replace_copy(borrowed<true>{}, nullptr_to<int>, 42, 5)),
static_assert(same_as<decltype(ranges::replace_copy(borrowed<true>{}, nullptr_to<int>, 42, 5)),
ranges::replace_copy_result<int*, int*>>);
struct instantiator {
@ -33,7 +33,7 @@ struct instantiator {
auto result =
replace_copy(wrapped_input.begin(), wrapped_input.end(), Write{output}, 47, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), replace_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), replace_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 5);
assert(equal(output, expected));
@ -43,7 +43,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace_copy(wrapped_input, Write{output}, 47, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), replace_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), replace_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 5);
assert(equal(output, expected));
@ -53,7 +53,7 @@ struct instantiator {
int main() {
#ifndef _PREFAST_ // TRANSITION, GH-1030
STATIC_ASSERT((input_range_output_iterator_permutations<instantiator, P const, P>(), true));
static_assert((input_range_output_iterator_permutations<instantiator, P const, P>(), true));
#endif // TRANSITION, GH-1030
input_range_output_iterator_permutations<instantiator, P const, P>();
}

Просмотреть файл

@ -14,12 +14,12 @@ using P = pair<int, int>;
constexpr auto matches = [](int const val) { return val == 47; };
// Validate that replace_copy_if_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::replace_copy_if_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::replace_copy_if_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::replace_copy_if(borrowed<false>{}, nullptr_to<int>, matches, 5)),
static_assert(same_as<decltype(ranges::replace_copy_if(borrowed<false>{}, nullptr_to<int>, matches, 5)),
ranges::replace_copy_if_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::replace_copy_if(borrowed<true>{}, nullptr_to<int>, matches, 5)),
static_assert(same_as<decltype(ranges::replace_copy_if(borrowed<true>{}, nullptr_to<int>, matches, 5)),
ranges::replace_copy_if_result<int*, int*>>);
struct instantiator {
@ -35,7 +35,7 @@ struct instantiator {
auto result = replace_copy_if(
wrapped_input.begin(), wrapped_input.end(), Write{output}, matches, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), replace_copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), replace_copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 5);
assert(equal(output, expected));
@ -45,7 +45,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace_copy_if(wrapped_input, Write{output}, matches, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), replace_copy_if_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), replace_copy_if_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 5);
assert(equal(output, expected));
@ -55,7 +55,7 @@ struct instantiator {
int main() {
#ifndef _PREFAST_ // TRANSITION, GH-1030
STATIC_ASSERT((input_range_output_iterator_permutations<instantiator, P const, P>(), true));
static_assert((input_range_output_iterator_permutations<instantiator, P const, P>(), true));
#endif // TRANSITION, GH-1030
input_range_output_iterator_permutations<instantiator, P const, P>();
}

Просмотреть файл

@ -14,8 +14,8 @@ using P = pair<int, int>;
constexpr auto matches = [](int const val) { return val == 47; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::replace_if(borrowed<false>{}, matches, 5)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::replace_if(borrowed<true>{}, matches, 5)), int*>);
static_assert(same_as<decltype(ranges::replace_if(borrowed<false>{}, matches, 5)), ranges::dangling>);
static_assert(same_as<decltype(ranges::replace_if(borrowed<true>{}, matches, 5)), int*>);
struct instantiator {
static constexpr P output[5] = {{0, 99}, {47, 1}, {2, 99}, {47, 1}, {4, 99}};
@ -28,7 +28,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace_if(wrapped_input.begin(), wrapped_input.end(), matches, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), ranges::iterator_t<Read>>);
static_assert(same_as<decltype(result), ranges::iterator_t<Read>>);
assert(result == wrapped_input.end());
assert(ranges::equal(output, input));
}
@ -37,7 +37,7 @@ struct instantiator {
Read wrapped_input{input};
auto result = replace_if(wrapped_input, matches, P{47, 1}, get_second);
STATIC_ASSERT(same_as<decltype(result), ranges::iterator_t<Read>>);
static_assert(same_as<decltype(result), ranges::iterator_t<Read>>);
assert(result == wrapped_input.end());
assert(ranges::equal(output, input));
}
@ -45,6 +45,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in<instantiator, P>(), true));
static_assert((test_in<instantiator, P>(), true));
test_in<instantiator, P>();
}

Просмотреть файл

@ -15,8 +15,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::reverse(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::reverse(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::reverse(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::reverse(borrowed<true>{})), int*>);
struct nontrivial_int {
int val;
@ -43,7 +43,7 @@ struct instantiator {
nontrivial_int input[] = {13, 42, 1367};
R wrapped_input{input};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, expected_odd));
}
@ -51,7 +51,7 @@ struct instantiator {
nontrivial_int input[] = {13, 42, 1367};
R wrapped_input{input};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, expected_odd));
}
@ -59,7 +59,7 @@ struct instantiator {
nontrivial_int input[] = {13, 42, 1367, 1729};
R wrapped_input{input};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, expected_even));
}
@ -67,20 +67,20 @@ struct instantiator {
nontrivial_int input[] = {13, 42, 1367, 1729};
R wrapped_input{input};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, expected_even));
}
{ // Validate iterator + sentinel overload, empty range
R wrapped_input{span<nontrivial_int, 0>{}};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
}
{ // Validate range overload, empty range
R wrapped_input{span<nontrivial_int, 0>{}};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
}
}
@ -106,7 +106,7 @@ struct test_vector {
ranges::range_value_t<R> input[]{0x10, 0x20, 0x30};
R wrapped_input{input};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, initializer_list<ranges::range_value_t<R>>{0x30, 0x20, 0x10}));
}
@ -114,7 +114,7 @@ struct test_vector {
ranges::range_value_t<R> input[]{0x10, 0x20, 0x30};
R wrapped_input{input};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, initializer_list<ranges::range_value_t<R>>{0x30, 0x20, 0x10}));
}
@ -123,7 +123,7 @@ struct test_vector {
ranges::range_value_t<R> input[]{0x10, 0x20, 0x30, 0x40};
R wrapped_input{input};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, initializer_list<ranges::range_value_t<R>>{0x40, 0x30, 0x20, 0x10}));
}
@ -131,7 +131,7 @@ struct test_vector {
ranges::range_value_t<R> input[]{0x10, 0x20, 0x30, 0x40};
R wrapped_input{input};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
assert(equal(input, initializer_list<ranges::range_value_t<R>>{0x40, 0x30, 0x20, 0x10}));
}
@ -139,34 +139,34 @@ struct test_vector {
{ // Validate iterator + sentinel overload, vectorizable empty
R wrapped_input{span<ranges::range_value_t<R>, 0>{}};
auto result = reverse(wrapped_input.begin(), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
}
{ // Validate range overload, vectorizable empty
R wrapped_input{span<ranges::range_value_t<R>, 0>{}};
auto result = reverse(wrapped_input);
STATIC_ASSERT(same_as<decltype(result), iterator_t<R>>);
static_assert(same_as<decltype(result), iterator_t<R>>);
assert(result == wrapped_input.end());
}
}
};
int main() {
STATIC_ASSERT((test_bidi<instantiator, nontrivial_int>(), true));
static_assert((test_bidi<instantiator, nontrivial_int>(), true));
test_bidi<instantiator, nontrivial_int>();
STATIC_ASSERT((test_contiguous<test_vector, bytes<1>>(), true));
static_assert((test_contiguous<test_vector, bytes<1>>(), true));
test_contiguous<test_vector, bytes<1>>();
STATIC_ASSERT((test_contiguous<test_vector, bytes<2>>(), true));
static_assert((test_contiguous<test_vector, bytes<2>>(), true));
test_contiguous<test_vector, bytes<2>>();
STATIC_ASSERT((test_contiguous<test_vector, bytes<4>>(), true));
static_assert((test_contiguous<test_vector, bytes<4>>(), true));
test_contiguous<test_vector, bytes<4>>();
STATIC_ASSERT((test_contiguous<test_vector, bytes<8>>(), true));
static_assert((test_contiguous<test_vector, bytes<8>>(), true));
test_contiguous<test_vector, bytes<8>>();
STATIC_ASSERT((test_contiguous<test_vector, bytes<3>>(), true));
static_assert((test_contiguous<test_vector, bytes<3>>(), true));
test_contiguous<test_vector, bytes<3>>();
}

Просмотреть файл

@ -15,12 +15,12 @@
using namespace std;
// Validate that reverse_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::reverse_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::reverse_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::reverse_copy(borrowed<false>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::reverse_copy(borrowed<false>{}, nullptr_to<int>)),
ranges::reverse_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::reverse_copy(borrowed<true>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::reverse_copy(borrowed<true>{}, nullptr_to<int>)),
ranges::reverse_copy_result<int*, int*>>);
struct nontrivial_int {
@ -151,19 +151,19 @@ struct test_vector {
// These tests take up a lot of memory,
// so we split them up into multiple functions to make sure the compiler doesn't run out of heap.
void test1() {
STATIC_ASSERT((test_bidi_write<instantiator, const nontrivial_int, nontrivial_int>(), true));
static_assert((test_bidi_write<instantiator, const nontrivial_int, nontrivial_int>(), true));
test_bidi_write<instantiator, const nontrivial_int, nontrivial_int>();
STATIC_ASSERT((test_contiguous_write<test_vector, const bytes<1>, bytes<1>>(), true));
STATIC_ASSERT((test_contiguous_write<test_vector, const bytes<2>, bytes<2>>(), true));
static_assert((test_contiguous_write<test_vector, const bytes<1>, bytes<1>>(), true));
static_assert((test_contiguous_write<test_vector, const bytes<2>, bytes<2>>(), true));
test_contiguous_write<test_vector, const bytes<1>, bytes<1>>();
test_contiguous_write<test_vector, const bytes<2>, bytes<2>>();
}
void test2() {
STATIC_ASSERT((test_contiguous_write<test_vector, const bytes<4>, bytes<4>>(), true));
STATIC_ASSERT((test_contiguous_write<test_vector, const bytes<8>, bytes<8>>(), true));
STATIC_ASSERT((test_contiguous_write<test_vector, const bytes<3>, bytes<3>>(), true));
static_assert((test_contiguous_write<test_vector, const bytes<4>, bytes<4>>(), true));
static_assert((test_contiguous_write<test_vector, const bytes<8>, bytes<8>>(), true));
static_assert((test_contiguous_write<test_vector, const bytes<3>, bytes<3>>(), true));
test_contiguous_write<test_vector, const bytes<4>, bytes<4>>();
test_contiguous_write<test_vector, const bytes<8>, bytes<8>>();
test_contiguous_write<test_vector, const bytes<3>, bytes<3>>();

Просмотреть файл

@ -12,8 +12,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::rotate(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::rotate(borrowed<true>{}, nullptr_to<int>)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::rotate(borrowed<false>{}, nullptr_to<int>)), ranges::dangling>);
static_assert(same_as<decltype(ranges::rotate(borrowed<true>{}, nullptr_to<int>)), ranges::subrange<int*>>);
struct instantiator {
static constexpr P expected[5] = {{3, 47}, {4, 99}, {0, 99}, {1, 47}, {2, 99}};
@ -26,7 +26,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = rotate(wrapped_input.begin(), next(wrapped_input.begin(), 3), wrapped_input.end());
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.begin() == next(wrapped_input.begin(), 2));
assert(result.end() == wrapped_input.end());
assert(equal(expected, input));
@ -36,7 +36,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = rotate(wrapped_input, next(wrapped_input.begin(), 3));
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.begin() == next(wrapped_input.begin(), 2));
assert(result.end() == wrapped_input.end());
assert(equal(expected, input));
@ -45,6 +45,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_fwd<instantiator, P>(), true));
static_assert((test_fwd<instantiator, P>(), true));
test_fwd<instantiator, P>();
}

Просмотреть файл

@ -10,12 +10,12 @@
using namespace std;
// Validate that rotate_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::rotate_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::rotate_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::rotate_copy(borrowed<false>{}, nullptr_to<int>, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::rotate_copy(borrowed<false>{}, nullptr_to<int>, nullptr_to<int>)),
ranges::rotate_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::rotate_copy(borrowed<true>{}, nullptr_to<int>, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::rotate_copy(borrowed<true>{}, nullptr_to<int>, nullptr_to<int>)),
ranges::rotate_copy_result<int*, int*>>);
struct instantiator {
@ -31,7 +31,7 @@ struct instantiator {
iterator_t<Read> mid = next(wrapped_input.begin(), 3);
auto result = rotate_copy(wrapped_input.begin(), mid, wrapped_input.end(), Write{output});
STATIC_ASSERT(same_as<decltype(result), rotate_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), rotate_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == end(output));
assert(equal(expected, output));
@ -42,7 +42,7 @@ struct instantiator {
iterator_t<Read> mid = next(wrapped_input.begin(), 3);
auto result = rotate_copy(wrapped_input, mid, Write{output});
STATIC_ASSERT(same_as<decltype(result), rotate_copy_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), rotate_copy_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == end(output));
assert(equal(expected, output));
@ -51,6 +51,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_fwd_write<instantiator, const int, int>(), true));
static_assert((test_fwd_write<instantiator, const int, int>(), true));
test_fwd_write<instantiator, const int, int>();
}

Просмотреть файл

@ -31,7 +31,7 @@ struct instantiator {
Read wrapped_input{reservoir};
auto result1 = sample(wrapped_input.begin(), wrapped_input.end(), Write{output1}, 3, gen);
STATIC_ASSERT(same_as<decltype(result1), Write>);
static_assert(same_as<decltype(result1), Write>);
assert(result1.peek() == end(output1));
// check repeatability
@ -55,7 +55,7 @@ struct instantiator {
Read wrapped_input{reservoir};
auto result1 = sample(wrapped_input, Write{output1}, 3, gen);
STATIC_ASSERT(same_as<decltype(result1), Write>);
static_assert(same_as<decltype(result1), Write>);
assert(result1.peek() == end(output1));
// check repeatability

Просмотреть файл

@ -17,8 +17,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::search(borrowed<false>{}, borrowed<true>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::search(borrowed<true>{}, borrowed<false>{})), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::search(borrowed<false>{}, borrowed<true>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::search(borrowed<true>{}, borrowed<false>{})), ranges::subrange<int*>>);
struct instantiator {
static constexpr array<P, 8> pairs = {
@ -35,14 +35,14 @@ struct instantiator {
// defaulted predicate and projections
{
auto result = ranges::search(range1, range1);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == range1.begin());
assert(result.end() == range1.end());
}
{
auto result = ranges::search(
ranges::begin(range2), ranges::end(range2), ranges::begin(range2), ranges::end(range2));
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
assert(result.begin() == range2.begin());
assert(result.end() == range2.end());
}
@ -54,14 +54,14 @@ struct instantiator {
// explicit predicate
{
auto result = ranges::search(range2, range2, ranges::equal_to{});
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
assert(result.begin() == range2.begin());
assert(result.end() == range2.end());
}
{
auto result = ranges::search(ranges::begin(range1), ranges::end(range1), ranges::begin(range1),
ranges::end(range1), ranges::equal_to{});
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == range1.begin());
assert(result.end() == range1.end());
}
@ -69,14 +69,14 @@ struct instantiator {
// explicit predicate and one projection
{
auto result = ranges::search(range1, range2, pred, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == ranges::next(range1.begin(), 2));
assert(result.end() == ranges::next(range1.begin(), 5));
}
{
auto result = ranges::search(ranges::begin(range1), ranges::end(range1), ranges::begin(range2),
ranges::end(range2), pred, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == ranges::next(range1.begin(), 2));
assert(result.end() == ranges::next(range1.begin(), 5));
}
@ -85,14 +85,14 @@ struct instantiator {
constexpr auto minus1 = [](int x) { return x - 1; };
{
auto result = ranges::search(range1, range2, pred, get_first, minus1);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == ranges::next(range1.begin(), 3));
assert(result.end() == ranges::next(range1.begin(), 6));
}
{
auto result = ranges::search(ranges::begin(range1), ranges::end(range1), ranges::begin(range2),
ranges::end(range2), pred, get_first, minus1);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd1>>>);
assert(result.begin() == ranges::next(range1.begin(), 3));
assert(result.end() == ranges::next(range1.begin(), 6));
}
@ -100,13 +100,13 @@ struct instantiator {
// negative case
{
auto result = ranges::search(range2, range1, pred, minus1, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
assert(result.empty());
}
{
auto result = ranges::search(ranges::begin(range2), ranges::end(range2), ranges::begin(range1),
ranges::end(range1), pred, minus1, get_first);
STATIC_ASSERT(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
static_assert(same_as<decltype(result), ranges::subrange<ranges::iterator_t<Fwd2>>>);
assert(result.empty());
}
}
@ -161,7 +161,7 @@ constexpr bool run_tests() {
const int haystack[] = {1, 2, 3, 1, 2, 3, 1, 2, 3};
const int needle[] = {1, 2, 3};
const auto result = ranges::search(span<const int>{haystack}, needle);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<span<const int>::iterator>>);
static_assert(same_as<decltype(result), const ranges::subrange<span<const int>::iterator>>);
assert(to_address(result.begin()) == haystack + 0);
assert(to_address(result.end()) == haystack + 3);
}
@ -187,10 +187,10 @@ constexpr void test_devcom_1559808() {
}
int main() {
STATIC_ASSERT(run_tests());
static_assert(run_tests());
run_tests();
STATIC_ASSERT((test_devcom_1559808(), true));
static_assert((test_devcom_1559808(), true));
test_devcom_1559808();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -13,8 +13,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::search_n(borrowed<false>{}, 13, 42)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::search_n(borrowed<true>{}, 42, 13)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::search_n(borrowed<false>{}, 13, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::search_n(borrowed<true>{}, 42, 13)), ranges::subrange<int*>>);
using P = pair<int, int>;
@ -29,13 +29,13 @@ struct instantiator {
// defaulted predicate and projections
{
const auto result = ranges::search_n(range, 2, P{1, 42});
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 1));
assert(result.end() == ranges::next(range.begin(), 3));
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), 2, P{1, 42});
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 1));
assert(result.end() == ranges::next(range.begin(), 3));
}
@ -43,14 +43,14 @@ struct instantiator {
// explicit predicate
{
const auto result = ranges::search_n(range, 2, P{1, 42}, ranges::equal_to{});
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 1));
assert(result.end() == ranges::next(range.begin(), 3));
}
{
const auto result =
ranges::search_n(ranges::begin(range), ranges::end(range), 2, P{1, 42}, ranges::equal_to{});
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 1));
assert(result.end() == ranges::next(range.begin(), 3));
}
@ -59,13 +59,13 @@ struct instantiator {
constexpr auto cmp = [](auto&& x, auto&& y) { return x == y + 1; };
{
const auto result = ranges::search_n(range, 3, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 7));
assert(result.end() == ranges::next(range.begin(), 10));
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), 3, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == ranges::next(range.begin(), 7));
assert(result.end() == ranges::next(range.begin(), 10));
}
@ -73,13 +73,13 @@ struct instantiator {
// negative case
{
const auto result = ranges::search_n(range, 4, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.end());
assert(result.end() == range.end());
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), 4, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.end());
assert(result.end() == range.end());
}
@ -87,13 +87,13 @@ struct instantiator {
// trivial case: empty needle
{
const auto result = ranges::search_n(range, 0, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.begin());
assert(result.end() == range.begin());
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), 0, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.begin());
assert(result.end() == range.begin());
}
@ -101,13 +101,13 @@ struct instantiator {
// trivial case: range too small
{
const auto result = ranges::search_n(range, 99999, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.end());
assert(result.end() == range.end());
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), 99999, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.end());
assert(result.end() == range.end());
}
@ -115,13 +115,13 @@ struct instantiator {
// trivial case: negative count
{
const auto result = ranges::search_n(range, -42, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.begin());
assert(result.end() == range.begin());
}
{
const auto result = ranges::search_n(ranges::begin(range), ranges::end(range), -42, 0, cmp, get_first);
STATIC_ASSERT(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
static_assert(same_as<decltype(result), const ranges::subrange<ranges::iterator_t<Fwd>>>);
assert(result.begin() == range.begin());
assert(result.end() == range.begin());
}
@ -130,6 +130,6 @@ struct instantiator {
int main() {
using Elem = const P;
STATIC_ASSERT((test_fwd<instantiator, Elem>(), true));
static_assert((test_fwd<instantiator, Elem>(), true));
test_fwd<instantiator, Elem>();
}

Просмотреть файл

@ -14,13 +14,13 @@ using namespace std;
using P = pair<int, int>;
// Validate that set_difference_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::set_difference_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::set_difference_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::set_difference(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_difference(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_difference_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_difference(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_difference(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_difference_result<int*, int*>>);
@ -123,6 +123,6 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}

Просмотреть файл

@ -14,20 +14,20 @@ using namespace std;
using P = pair<int, int>;
// Validate that set_intersection_result aliases in_in_out_result
STATIC_ASSERT(
static_assert(
same_as<ranges::set_intersection_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::set_intersection(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_intersection(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_intersection_result<ranges::dangling, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_intersection(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_intersection(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_intersection_result<ranges::dangling, int*, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_intersection(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_intersection(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_intersection_result<int*, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_intersection(
static_assert(same_as<decltype(ranges::set_intersection(
borrowed<true>{}, borrowed<true>{}, nullptr_to<int>, ranges::less{}, identity{}, identity{})),
ranges::set_intersection_result<int*, int*, int*>>);
@ -141,6 +141,6 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}

Просмотреть файл

@ -14,20 +14,20 @@ using namespace std;
using P = pair<int, int>;
// Validate that set_symmetric_difference_result aliases in_in_out_result
STATIC_ASSERT(
static_assert(
same_as<ranges::set_symmetric_difference_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::set_symmetric_difference(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_symmetric_difference(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_symmetric_difference_result<ranges::dangling, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_symmetric_difference(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_symmetric_difference(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_symmetric_difference_result<ranges::dangling, int*, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_symmetric_difference(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
static_assert(same_as<decltype(ranges::set_symmetric_difference(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>,
ranges::less{}, identity{}, identity{})),
ranges::set_symmetric_difference_result<int*, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_symmetric_difference(
static_assert(same_as<decltype(ranges::set_symmetric_difference(
borrowed<true>{}, borrowed<true>{}, nullptr_to<int>, ranges::less{}, identity{}, identity{})),
ranges::set_symmetric_difference_result<int*, int*, int*>>);
@ -138,6 +138,6 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}

Просмотреть файл

@ -14,19 +14,19 @@ using namespace std;
using P = pair<int, int>;
// Validate that set_union_result aliases in_in_out_result
STATIC_ASSERT(same_as<ranges::set_union_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
static_assert(same_as<ranges::set_union_result<int, void*, double>, ranges::in_in_out_result<int, void*, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::set_union(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>, ranges::less{},
static_assert(same_as<decltype(ranges::set_union(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>, ranges::less{},
identity{}, identity{})),
ranges::set_union_result<ranges::dangling, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_union(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>, ranges::less{},
static_assert(same_as<decltype(ranges::set_union(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>, ranges::less{},
identity{}, identity{})),
ranges::set_union_result<ranges::dangling, int*, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_union(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>, ranges::less{},
static_assert(same_as<decltype(ranges::set_union(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>, ranges::less{},
identity{}, identity{})),
ranges::set_union_result<int*, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::set_union(
static_assert(same_as<decltype(ranges::set_union(
borrowed<true>{}, borrowed<true>{}, nullptr_to<int>, ranges::less{}, identity{}, identity{})),
ranges::set_union_result<int*, int*, int*>>);
@ -134,6 +134,6 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}

Просмотреть файл

@ -16,8 +16,8 @@ const unsigned int seed = random_device{}();
mt19937 gen{seed};
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::shuffle(borrowed<false>{}, gen)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::shuffle(borrowed<true>{}, gen)), int*>);
static_assert(same_as<decltype(ranges::shuffle(borrowed<false>{}, gen)), ranges::dangling>);
static_assert(same_as<decltype(ranges::shuffle(borrowed<true>{}, gen)), int*>);
struct instantiator {
static constexpr int expected[7] = {1, 2, 3, 4, 5, 6, 7};
@ -31,7 +31,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = shuffle(wrapped_input.begin(), wrapped_input.end(), gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<ReadWrite>>);
static_assert(same_as<decltype(result), iterator_t<ReadWrite>>);
assert(result == wrapped_input.end());
sort(begin(input), end(input));
@ -42,7 +42,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = shuffle(wrapped_input, gen);
STATIC_ASSERT(same_as<decltype(result), iterator_t<ReadWrite>>);
static_assert(same_as<decltype(result), iterator_t<ReadWrite>>);
assert(result == wrapped_input.end());
sort(begin(input), end(input));
@ -64,7 +64,7 @@ void test_urbg() { // COMPILE-ONLY
}
};
STATIC_ASSERT(uniform_random_bit_generator<RandGen>);
static_assert(uniform_random_bit_generator<RandGen>);
int arr[1] = {};
ranges::shuffle(arr, RandGen{});

Просмотреть файл

@ -16,8 +16,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::sort(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::sort(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::sort(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::sort(borrowed<true>{})), int*>);
struct instantiator {
static constexpr array input = {P{-1200257975, 0}, P{-1260655766, 1}, P{-1298559576, 2}, P{-1459960308, 3},
@ -62,9 +62,9 @@ constexpr void test_devcom_1559808() {
}
int main() {
STATIC_ASSERT((test_random<instantiator, P>(), true));
static_assert((test_random<instantiator, P>(), true));
test_random<instantiator, P>();
STATIC_ASSERT((test_devcom_1559808(), true));
static_assert((test_devcom_1559808(), true));
test_devcom_1559808();
}

Просмотреть файл

@ -16,8 +16,8 @@ using P = pair<int, int>;
constexpr auto is_even = [](int i) { return i % 2 == 0; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::stable_partition(borrowed<false>{}, is_even)), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::stable_partition(borrowed<true>{}, is_even)), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::stable_partition(borrowed<false>{}, is_even)), ranges::dangling>);
static_assert(same_as<decltype(ranges::stable_partition(borrowed<true>{}, is_even)), ranges::subrange<int*>>);
struct instantiator {
template <ranges::bidirectional_range Range>

Просмотреть файл

@ -15,8 +15,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::stable_sort(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::stable_sort(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::stable_sort(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::stable_sort(borrowed<true>{})), int*>);
struct instantiator {
static constexpr array input = {P{1, 0}, P{-1260655766, 1}, P{-1298559576, 2}, P{1, 3}, P{-2095681771, 4},

Просмотреть файл

@ -11,16 +11,16 @@
using namespace std;
// Validate that swap_ranges_result aliases in_in_result
STATIC_ASSERT(same_as<ranges::swap_ranges_result<int, double>, ranges::in_in_result<int, double>>);
static_assert(same_as<ranges::swap_ranges_result<int, double>, ranges::in_in_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::swap_ranges(borrowed<false>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::swap_ranges(borrowed<false>{}, borrowed<false>{})),
ranges::swap_ranges_result<ranges::dangling, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::swap_ranges(borrowed<true>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::swap_ranges(borrowed<true>{}, borrowed<false>{})),
ranges::swap_ranges_result<int*, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::swap_ranges(borrowed<false>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::swap_ranges(borrowed<false>{}, borrowed<true>{})),
ranges::swap_ranges_result<ranges::dangling, int*>>);
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::swap_ranges(borrowed<true>{}, borrowed<true>{})), ranges::swap_ranges_result<int*, int*>>);
struct instantiator {
@ -38,7 +38,7 @@ struct instantiator {
auto result =
swap_ranges(wrapped_input1.begin(), wrapped_input1.end(), wrapped_input2.begin(), wrapped_input2.end());
STATIC_ASSERT(
static_assert(
same_as<decltype(result), swap_ranges_result<iterator_t<ReadWrite1>, iterator_t<ReadWrite2>>>);
assert(result.in1 == wrapped_input1.end());
assert(result.in2 == wrapped_input2.end());
@ -52,7 +52,7 @@ struct instantiator {
ReadWrite2 wrapped_input2{input2};
auto result = swap_ranges(wrapped_input1, wrapped_input2);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), swap_ranges_result<iterator_t<ReadWrite1>, iterator_t<ReadWrite2>>>);
assert(result.in1 == wrapped_input1.end());
assert(result.in2 == wrapped_input2.end());
@ -100,7 +100,7 @@ constexpr void run_tests() {
}
int main() {
STATIC_ASSERT((run_tests(), true));
static_assert((run_tests(), true));
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -13,16 +13,16 @@ using namespace std;
using P = pair<int, int>;
// Validate that binary_transform_result aliases in_in_out_result
STATIC_ASSERT(same_as<ranges::binary_transform_result<int, P, double>, ranges::in_in_out_result<int, P, double>>);
static_assert(same_as<ranges::binary_transform_result<int, P, double>, ranges::in_in_out_result<int, P, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>, plus{})),
static_assert(same_as<decltype(ranges::transform(borrowed<false>{}, borrowed<false>{}, nullptr_to<int>, plus{})),
ranges::binary_transform_result<ranges::dangling, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>, plus{})),
static_assert(same_as<decltype(ranges::transform(borrowed<false>{}, borrowed<true>{}, nullptr_to<int>, plus{})),
ranges::binary_transform_result<ranges::dangling, int*, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>, plus{})),
static_assert(same_as<decltype(ranges::transform(borrowed<true>{}, borrowed<false>{}, nullptr_to<int>, plus{})),
ranges::binary_transform_result<int*, ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<true>{}, borrowed<true>{}, nullptr_to<int>, plus{})),
static_assert(same_as<decltype(ranges::transform(borrowed<true>{}, borrowed<true>{}, nullptr_to<int>, plus{})),
ranges::binary_transform_result<int*, int*, int*>>);
struct instantiator {
@ -44,7 +44,7 @@ struct instantiator {
auto result = transform(wrapped_in1.begin(), wrapped_in1.end(), wrapped_in2.begin(), wrapped_in2.end(),
Write{output}, plus{}, get_first, get_second);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), binary_transform_result<iterator_t<Read1>, iterator_t<Read2>, Write>>);
assert(result.in1 == wrapped_in1.end());
assert(next(result.in2) == wrapped_in2.end());
@ -58,7 +58,7 @@ struct instantiator {
auto result = transform(wrapped_in1.begin(), wrapped_in1.end(), wrapped_in2.begin(), wrapped_in2.end(),
Write{output}, plus{}, get_first, get_second);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), binary_transform_result<iterator_t<Read1>, iterator_t<Read2>, Write>>);
assert(next(result.in1) == wrapped_in1.end());
assert(result.in2 == wrapped_in2.end());
@ -71,7 +71,7 @@ struct instantiator {
Read2 wrapped_in2{input2};
auto result = transform(wrapped_in1, wrapped_in2, Write{output}, plus{}, get_first, get_second);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), binary_transform_result<iterator_t<Read1>, iterator_t<Read2>, Write>>);
assert(result.in1 == wrapped_in1.end());
assert(next(result.in2) == wrapped_in2.end());
@ -84,7 +84,7 @@ struct instantiator {
Read2 wrapped_in2{shortInput2};
auto result = transform(wrapped_in1, wrapped_in2, Write{output}, plus{}, get_first, get_second);
STATIC_ASSERT(
static_assert(
same_as<decltype(result), binary_transform_result<iterator_t<Read1>, iterator_t<Read2>, Write>>);
assert(next(result.in1) == wrapped_in1.end());
assert(result.in2 == wrapped_in2.end());
@ -122,7 +122,7 @@ constexpr bool run_tests() {
}
int main() {
STATIC_ASSERT(run_tests());
static_assert(run_tests());
run_tests();
}
#endif // TEST_EVERYTHING

Просмотреть файл

@ -13,14 +13,14 @@ using namespace std;
using P = pair<int, int>;
// Validate that unary_transform_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::unary_transform_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::unary_transform_result<int, double>, ranges::in_out_result<int, double>>);
constexpr auto minus_one = [](const int x) { return x - 1; };
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<false>{}, nullptr_to<int>, minus_one)),
static_assert(same_as<decltype(ranges::transform(borrowed<false>{}, nullptr_to<int>, minus_one)),
ranges::unary_transform_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::transform(borrowed<true>{}, nullptr_to<int>, minus_one)),
static_assert(same_as<decltype(ranges::transform(borrowed<true>{}, nullptr_to<int>, minus_one)),
ranges::unary_transform_result<int*, int*>>);
struct instantiator {
@ -35,7 +35,7 @@ struct instantiator {
Read wrapped_in{input};
auto result = transform(wrapped_in.begin(), wrapped_in.end(), Write{output}, minus_one, get_first);
STATIC_ASSERT(same_as<decltype(result), unary_transform_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), unary_transform_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_in.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, expected));
@ -45,7 +45,7 @@ struct instantiator {
Read wrapped_in{input};
auto result = transform(wrapped_in, Write{output}, minus_one, get_first);
STATIC_ASSERT(same_as<decltype(result), unary_transform_result<iterator_t<Read>, Write>>);
static_assert(same_as<decltype(result), unary_transform_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_in.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, expected));
@ -54,6 +54,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT((test_in_write<instantiator, const P, int>(), true));
static_assert((test_in_write<instantiator, const P, int>(), true));
test_in_write<instantiator, const P, int>();
}

Просмотреть файл

@ -26,16 +26,16 @@ void unused_function() {
using namespace std;
// Validate that uninitialized_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::uninitialized_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::uninitialized_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_copy(borrowed<false>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::uninitialized_copy(borrowed<false>{}, borrowed<false>{})),
ranges::uninitialized_copy_result<ranges::dangling, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_copy(borrowed<false>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::uninitialized_copy(borrowed<false>{}, borrowed<true>{})),
ranges::uninitialized_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_copy(borrowed<true>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::uninitialized_copy(borrowed<true>{}, borrowed<false>{})),
ranges::uninitialized_copy_result<int*, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_copy(borrowed<true>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::uninitialized_copy(borrowed<true>{}, borrowed<true>{})),
ranges::uninitialized_copy_result<int*, int*>>);
struct int_wrapper {

Просмотреть файл

@ -16,7 +16,7 @@
using namespace std;
// Validate that uninitialized_copy_n_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::uninitialized_copy_n_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::uninitialized_copy_n_result<int, double>, ranges::in_out_result<int, double>>);
struct int_wrapper {
inline static int constructions = 0;

Просмотреть файл

@ -14,8 +14,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_default_construct(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_default_construct(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::uninitialized_default_construct(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::uninitialized_default_construct(borrowed<false>{})), ranges::dangling>);
struct int_wrapper {
inline static int constructions = 0;
@ -41,7 +41,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
struct instantiator {
template <ranges::forward_range Write>

Просмотреть файл

@ -37,7 +37,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
struct instantiator {
template <ranges::forward_range Write>

Просмотреть файл

@ -14,8 +14,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_fill(borrowed<true>{}, 42)), int*>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_fill(borrowed<false>{}, 42)), ranges::dangling>);
static_assert(same_as<decltype(ranges::uninitialized_fill(borrowed<true>{}, 42)), int*>);
static_assert(same_as<decltype(ranges::uninitialized_fill(borrowed<false>{}, 42)), ranges::dangling>);
struct int_wrapper {
inline static int constructions = 0;
@ -44,7 +44,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -40,7 +40,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -15,16 +15,16 @@
using namespace std;
// Validate that uninitialized_move_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::uninitialized_move_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::uninitialized_move_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_move(borrowed<false>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::uninitialized_move(borrowed<false>{}, borrowed<false>{})),
ranges::uninitialized_move_result<ranges::dangling, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_move(borrowed<false>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::uninitialized_move(borrowed<false>{}, borrowed<true>{})),
ranges::uninitialized_move_result<ranges::dangling, int*>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_move(borrowed<true>{}, borrowed<false>{})),
static_assert(same_as<decltype(ranges::uninitialized_move(borrowed<true>{}, borrowed<false>{})),
ranges::uninitialized_move_result<int*, ranges::dangling>>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_move(borrowed<true>{}, borrowed<true>{})),
static_assert(same_as<decltype(ranges::uninitialized_move(borrowed<true>{}, borrowed<true>{})),
ranges::uninitialized_move_result<int*, int*>>);
struct int_wrapper {
@ -65,7 +65,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(movable<int_wrapper> && !copyable<int_wrapper>);
static_assert(movable<int_wrapper> && !copyable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -16,7 +16,7 @@
using namespace std;
// Validate that uninitialized_move_n_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::uninitialized_move_n_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::uninitialized_move_n_result<int, double>, ranges::in_out_result<int, double>>);
struct int_wrapper {
inline static int constructions = 0;
@ -56,7 +56,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(movable<int_wrapper> && !copyable<int_wrapper>);
static_assert(movable<int_wrapper> && !copyable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -14,8 +14,8 @@
using namespace std;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_value_construct(borrowed<true>{})), int*>);
STATIC_ASSERT(same_as<decltype(ranges::uninitialized_value_construct(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::uninitialized_value_construct(borrowed<true>{})), int*>);
static_assert(same_as<decltype(ranges::uninitialized_value_construct(borrowed<false>{})), ranges::dangling>);
struct int_wrapper {
inline static int constructions = 0;
@ -41,7 +41,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -37,7 +37,7 @@ struct int_wrapper {
auto operator<=>(const int_wrapper&) const = default;
};
STATIC_ASSERT(default_initializable<int_wrapper>);
static_assert(default_initializable<int_wrapper>);
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto get_int_wrapper_val = [](const int_wrapper& w) { return w.val; };

Просмотреть файл

@ -13,8 +13,8 @@ using namespace std;
using P = pair<int, int>;
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::unique(borrowed<false>{})), ranges::dangling>);
STATIC_ASSERT(same_as<decltype(ranges::unique(borrowed<true>{})), ranges::subrange<int*>>);
static_assert(same_as<decltype(ranges::unique(borrowed<false>{})), ranges::dangling>);
static_assert(same_as<decltype(ranges::unique(borrowed<true>{})), ranges::subrange<int*>>);
struct instantiator {
static constexpr P expected[4] = {{0, 99}, {1, 47}, {3, 99}, {4, 47}};
@ -38,7 +38,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = unique(wrapped_input.begin(), wrapped_input.end(), countedEq, get_second);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.begin() == next(wrapped_input.begin(), 4));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<4>()));
@ -50,7 +50,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = unique(wrapped_input.begin(), wrapped_input.end(), countedEq, get_second);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.empty());
}
@ -61,7 +61,7 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = unique(wrapped_input, countedEq, get_second);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.begin() == next(wrapped_input.begin(), 4));
assert(result.end() == wrapped_input.end());
assert(equal(expected, span{input}.first<4>()));
@ -73,13 +73,13 @@ struct instantiator {
ReadWrite wrapped_input{input};
auto result = unique(wrapped_input, countedEq, get_second);
STATIC_ASSERT(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
static_assert(same_as<decltype(result), subrange<iterator_t<ReadWrite>>>);
assert(result.empty());
}
}
};
int main() {
STATIC_ASSERT((test_fwd<instantiator, P>(), true));
static_assert((test_fwd<instantiator, P>(), true));
test_fwd<instantiator, P>();
}

Просмотреть файл

@ -13,12 +13,12 @@ using namespace std;
using P = pair<int, int>;
// Validate that unique_copy_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::unique_copy_result<int, double>, ranges::in_out_result<int, double>>);
static_assert(same_as<ranges::unique_copy_result<int, double>, ranges::in_out_result<int, double>>);
// Validate dangling story
STATIC_ASSERT(same_as<decltype(ranges::unique_copy(borrowed<false>{}, nullptr_to<int>)),
static_assert(same_as<decltype(ranges::unique_copy(borrowed<false>{}, nullptr_to<int>)),
ranges::unique_copy_result<ranges::dangling, int*>>);
STATIC_ASSERT(
static_assert(
same_as<decltype(ranges::unique_copy(borrowed<true>{}, nullptr_to<int>)), ranges::unique_copy_result<int*, int*>>);
constexpr P expectedInputRead[6] = {{0, 99}, {1, 47}, {1, 47}, {1, 99}, {1, 47}, {1, 47}};
@ -107,8 +107,8 @@ struct test_range_overload {
#ifdef TEST_EVERYTHING
int main() {
#ifndef _PREFAST_ // TRANSITION, GH-1030
STATIC_ASSERT((test_in_write<test_iterator_overload, P, P>(), true));
STATIC_ASSERT((test_in_write<test_range_overload, P, P>(), true));
static_assert((test_in_write<test_iterator_overload, P, P>(), true));
static_assert((test_in_write<test_range_overload, P, P>(), true));
#endif // TRANSITION, GH-1030
test_in_write<test_iterator_overload, P, P>();
test_in_write<test_range_overload, P, P>();
@ -154,7 +154,7 @@ void test_gh_1932() {
}
int main() {
STATIC_ASSERT(run_tests());
static_assert(run_tests());
run_tests();
test_gh_1932();

Просмотреть файл

@ -15,8 +15,6 @@
#pragma warning(disable : 4793) // function compiled as native: non-clrcall vcall thunks must be compiled as native
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
namespace ranges = std::ranges;
template <bool>
@ -48,8 +46,8 @@ struct simple_iter_archetype {
// clang-format on
friend void iter_swap(simple_iter_archetype const&, simple_iter_archetype const&) {}
};
STATIC_ASSERT(!std::indirectly_readable<simple_iter_archetype<0>>);
STATIC_ASSERT(std::indirectly_readable<simple_iter_archetype<1>>);
static_assert(!std::indirectly_readable<simple_iter_archetype<0>>);
static_assert(std::indirectly_readable<simple_iter_archetype<1>>);
template <class T, template <class> class TQuals, template <class> class UQuals>
struct std::basic_common_reference<T, ::simple_reference<T>, TQuals, UQuals> {
@ -97,18 +95,18 @@ namespace indirectly_unary_invocable_test {
template <class F, class I>
constexpr bool test() {
constexpr bool result = std::indirectly_unary_invocable<F, I>;
STATIC_ASSERT(result == std::indirectly_regular_unary_invocable<F, I>);
static_assert(result == std::indirectly_regular_unary_invocable<F, I>);
return result;
}
STATIC_ASSERT(!test<Fn<0>, simple_iter_archetype<1>>());
STATIC_ASSERT(!test<Fn<1>, simple_iter_archetype<1>>());
STATIC_ASSERT(!test<Fn<2>, simple_iter_archetype<1>>());
STATIC_ASSERT(!test<Fn<3>, simple_iter_archetype<1>>());
STATIC_ASSERT(!test<Fn<4>, simple_iter_archetype<1>>());
STATIC_ASSERT(!test<Fn<5>, simple_iter_archetype<0>>());
STATIC_ASSERT(test<Fn<5>, simple_iter_archetype<1>>());
static_assert(!test<Fn<0>, simple_iter_archetype<1>>());
static_assert(!test<Fn<1>, simple_iter_archetype<1>>());
static_assert(!test<Fn<2>, simple_iter_archetype<1>>());
static_assert(!test<Fn<3>, simple_iter_archetype<1>>());
static_assert(!test<Fn<4>, simple_iter_archetype<1>>());
static_assert(!test<Fn<5>, simple_iter_archetype<0>>());
static_assert(test<Fn<5>, simple_iter_archetype<1>>());
STATIC_ASSERT(std::same_as<std::indirect_result_t<Fn<5>, simple_iter_archetype<1>>, int>);
static_assert(std::same_as<std::indirect_result_t<Fn<5>, simple_iter_archetype<1>>, int>);
} // namespace indirectly_unary_invocable_test
namespace indirect_unary_predicate_test {
@ -141,15 +139,15 @@ namespace indirect_unary_predicate_test {
// clang-format on
};
STATIC_ASSERT(!indirect_unary_predicate<Fn<0>, simple_iter_archetype<1>>);
STATIC_ASSERT(!indirect_unary_predicate<Fn<1>, simple_iter_archetype<1>>);
STATIC_ASSERT(!indirect_unary_predicate<Fn<2>, simple_iter_archetype<1>>);
STATIC_ASSERT(!indirect_unary_predicate<Fn<3>, simple_iter_archetype<1>>);
STATIC_ASSERT(!indirect_unary_predicate<Fn<4>, simple_iter_archetype<1>>);
STATIC_ASSERT(!indirect_unary_predicate<Fn<5>, simple_iter_archetype<0>>);
STATIC_ASSERT(indirect_unary_predicate<Fn<5>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<0>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<1>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<2>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<3>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<4>, simple_iter_archetype<1>>);
static_assert(!indirect_unary_predicate<Fn<5>, simple_iter_archetype<0>>);
static_assert(indirect_unary_predicate<Fn<5>, simple_iter_archetype<1>>);
STATIC_ASSERT(std::same_as<std::indirect_result_t<Fn<5>, simple_iter_archetype<1>>, int>);
static_assert(std::same_as<std::indirect_result_t<Fn<5>, simple_iter_archetype<1>>, int>);
} // namespace indirect_unary_predicate_test
namespace indirect_binary_predicate_test {
@ -194,43 +192,43 @@ namespace indirect_binary_predicate_test {
using I2 = simple_iter_archetype<IterSelector2>;
constexpr bool result = indirect_binary_predicate<F, I1, I2>;
STATIC_ASSERT(indirect_equivalence_relation<F, I1, I2> == result);
STATIC_ASSERT(indirect_strict_weak_order<F, I1, I2> == result);
static_assert(indirect_equivalence_relation<F, I1, I2> == result);
static_assert(indirect_strict_weak_order<F, I1, I2> == result);
return result;
}
STATIC_ASSERT(!test<0, 1, 1>());
STATIC_ASSERT(!test<1, 1, 1>());
STATIC_ASSERT(!test<2, 1, 1>());
STATIC_ASSERT(!test<3, 1, 1>());
STATIC_ASSERT(!test<4, 1, 1>());
STATIC_ASSERT(!test<5, 1, 1>());
static_assert(!test<0, 1, 1>());
static_assert(!test<1, 1, 1>());
static_assert(!test<2, 1, 1>());
static_assert(!test<3, 1, 1>());
static_assert(!test<4, 1, 1>());
static_assert(!test<5, 1, 1>());
STATIC_ASSERT(!test<6, 0, 1>());
STATIC_ASSERT(!test<6, 1, 0>());
STATIC_ASSERT(test<6, 1, 1>());
static_assert(!test<6, 0, 1>());
static_assert(!test<6, 1, 0>());
static_assert(test<6, 1, 1>());
STATIC_ASSERT(std::same_as<std::indirect_result_t<Fn<6>, simple_iter_archetype<1>, simple_iter_archetype<1>>,
static_assert(std::same_as<std::indirect_result_t<Fn<6>, simple_iter_archetype<1>, simple_iter_archetype<1>>,
std::true_type>);
} // namespace indirect_binary_predicate_test
namespace projected_test {
template <class Iter, class Proj, class Value, class Reference>
constexpr bool test() {
STATIC_ASSERT(std::indirectly_readable<Iter>);
static_assert(std::indirectly_readable<Iter>);
using P = std::projected<Iter, Proj>;
STATIC_ASSERT(std::indirectly_readable<P>);
STATIC_ASSERT(std::same_as<std::iter_value_t<P>, Value>);
STATIC_ASSERT(std::same_as<std::iter_reference_t<P>, Reference>);
static_assert(std::indirectly_readable<P>);
static_assert(std::same_as<std::iter_value_t<P>, Value>);
static_assert(std::same_as<std::iter_reference_t<P>, Reference>);
return true;
}
STATIC_ASSERT(test<int*, std::identity, int, int&>());
STATIC_ASSERT(test<int const*, std::identity, int, int const&>());
static_assert(test<int*, std::identity, int, int&>());
static_assert(test<int const*, std::identity, int, int const&>());
struct S {};
STATIC_ASSERT(test<S*, int(S::*), int, int&>());
STATIC_ASSERT(test<S const*, int(S::*), int, int const&>());
static_assert(test<S*, int(S::*), int, int&>());
static_assert(test<S const*, int(S::*), int, int const&>());
struct iter {
using value_type = int;
@ -239,8 +237,8 @@ namespace projected_test {
};
reference operator*() const;
};
STATIC_ASSERT(test<iter, std::identity, iter::reference, iter::reference&&>());
STATIC_ASSERT(test<iter, double (*)(int), double, double>());
static_assert(test<iter, std::identity, iter::reference, iter::reference&&>());
static_assert(test<iter, double (*)(int), double, double>());
} // namespace projected_test
namespace indirectly_movable_test { // also covers indirectly_movable_storable
@ -264,18 +262,18 @@ namespace indirectly_movable_test { // also covers indirectly_movable_storable
// clang-format on
};
// Ensure specializations of value_type have the intended properties
STATIC_ASSERT(!movable<value_type<0>>);
STATIC_ASSERT(constructible_from<value_type<0>, simple_reference<value_type<0>>>);
STATIC_ASSERT(assignable_from<value_type<0>&, simple_reference<value_type<0>>>);
STATIC_ASSERT(movable<value_type<1>>);
STATIC_ASSERT(!constructible_from<value_type<1>, simple_reference<value_type<1>>>);
STATIC_ASSERT(assignable_from<value_type<1>&, simple_reference<value_type<1>>>);
STATIC_ASSERT(movable<value_type<2>>);
STATIC_ASSERT(constructible_from<value_type<2>, simple_reference<value_type<2>>>);
STATIC_ASSERT(!assignable_from<value_type<2>&, simple_reference<value_type<2>>>);
STATIC_ASSERT(movable<value_type<3>>);
STATIC_ASSERT(constructible_from<value_type<3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(assignable_from<value_type<3>&, simple_reference<value_type<3>>>);
static_assert(!movable<value_type<0>>);
static_assert(constructible_from<value_type<0>, simple_reference<value_type<0>>>);
static_assert(assignable_from<value_type<0>&, simple_reference<value_type<0>>>);
static_assert(movable<value_type<1>>);
static_assert(!constructible_from<value_type<1>, simple_reference<value_type<1>>>);
static_assert(assignable_from<value_type<1>&, simple_reference<value_type<1>>>);
static_assert(movable<value_type<2>>);
static_assert(constructible_from<value_type<2>, simple_reference<value_type<2>>>);
static_assert(!assignable_from<value_type<2>&, simple_reference<value_type<2>>>);
static_assert(movable<value_type<3>>);
static_assert(constructible_from<value_type<3>, simple_reference<value_type<3>>>);
static_assert(assignable_from<value_type<3>&, simple_reference<value_type<3>>>);
template <int I, int J>
struct out_archetype {
@ -290,25 +288,25 @@ namespace indirectly_movable_test { // also covers indirectly_movable_storable
// clang-format on
};
// Ensure specializations of out_archetype have the intended properties
STATIC_ASSERT(!indirectly_writable<out_archetype<0, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<0, 3>, value_type<3>>);
STATIC_ASSERT(indirectly_writable<out_archetype<1, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(!indirectly_writable<out_archetype<1, 3>, value_type<3>>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, value_type<3>>);
static_assert(!indirectly_writable<out_archetype<0, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<0, 3>, value_type<3>>);
static_assert(indirectly_writable<out_archetype<1, 3>, simple_reference<value_type<3>>>);
static_assert(!indirectly_writable<out_archetype<1, 3>, value_type<3>>);
static_assert(indirectly_writable<out_archetype<2, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<2, 3>, value_type<3>>);
// Validate indirectly_movable
STATIC_ASSERT(!indirectly_movable<simple_iter_archetype<0, value_type<3>>, out_archetype<1, 3>>);
STATIC_ASSERT(!indirectly_movable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
STATIC_ASSERT(indirectly_movable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
static_assert(!indirectly_movable<simple_iter_archetype<0, value_type<3>>, out_archetype<1, 3>>);
static_assert(!indirectly_movable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
static_assert(indirectly_movable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
// Validate indirectly_movable_storable
STATIC_ASSERT(!indirectly_movable_storable<simple_iter_archetype<0, value_type<3>>, out_archetype<2, 3>>);
STATIC_ASSERT(!indirectly_movable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
STATIC_ASSERT(!indirectly_movable_storable<simple_iter_archetype<1, value_type<0>>, out_archetype<2, 0>>);
STATIC_ASSERT(!indirectly_movable_storable<simple_iter_archetype<1, value_type<1>>, out_archetype<2, 1>>);
STATIC_ASSERT(!indirectly_movable_storable<simple_iter_archetype<1, value_type<2>>, out_archetype<2, 2>>);
STATIC_ASSERT(indirectly_movable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<2, 3>>);
static_assert(!indirectly_movable_storable<simple_iter_archetype<0, value_type<3>>, out_archetype<2, 3>>);
static_assert(!indirectly_movable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
static_assert(!indirectly_movable_storable<simple_iter_archetype<1, value_type<0>>, out_archetype<2, 0>>);
static_assert(!indirectly_movable_storable<simple_iter_archetype<1, value_type<1>>, out_archetype<2, 1>>);
static_assert(!indirectly_movable_storable<simple_iter_archetype<1, value_type<2>>, out_archetype<2, 2>>);
static_assert(indirectly_movable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<2, 3>>);
} // namespace indirectly_movable_test
namespace indirectly_copyable_test { // also covers indirectly_copyable_storable
@ -332,18 +330,18 @@ namespace indirectly_copyable_test { // also covers indirectly_copyable_storable
// clang-format on
};
// Ensure specializations of value_type have the intended properties
STATIC_ASSERT(!copyable<value_type<0>>);
STATIC_ASSERT(constructible_from<value_type<0>, simple_reference<value_type<0>>>);
STATIC_ASSERT(assignable_from<value_type<0>&, simple_reference<value_type<0>>>);
STATIC_ASSERT(copyable<value_type<1>>);
STATIC_ASSERT(!constructible_from<value_type<1>, simple_reference<value_type<1>>>);
STATIC_ASSERT(assignable_from<value_type<1>&, simple_reference<value_type<1>>>);
STATIC_ASSERT(copyable<value_type<2>>);
STATIC_ASSERT(constructible_from<value_type<2>, simple_reference<value_type<2>>>);
STATIC_ASSERT(!assignable_from<value_type<2>&, simple_reference<value_type<2>>>);
STATIC_ASSERT(copyable<value_type<3>>);
STATIC_ASSERT(constructible_from<value_type<3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(assignable_from<value_type<3>&, simple_reference<value_type<3>>>);
static_assert(!copyable<value_type<0>>);
static_assert(constructible_from<value_type<0>, simple_reference<value_type<0>>>);
static_assert(assignable_from<value_type<0>&, simple_reference<value_type<0>>>);
static_assert(copyable<value_type<1>>);
static_assert(!constructible_from<value_type<1>, simple_reference<value_type<1>>>);
static_assert(assignable_from<value_type<1>&, simple_reference<value_type<1>>>);
static_assert(copyable<value_type<2>>);
static_assert(constructible_from<value_type<2>, simple_reference<value_type<2>>>);
static_assert(!assignable_from<value_type<2>&, simple_reference<value_type<2>>>);
static_assert(copyable<value_type<3>>);
static_assert(constructible_from<value_type<3>, simple_reference<value_type<3>>>);
static_assert(assignable_from<value_type<3>&, simple_reference<value_type<3>>>);
template <int I, int J>
struct out_archetype {
@ -367,58 +365,58 @@ namespace indirectly_copyable_test { // also covers indirectly_copyable_storable
// clang-format on
};
// Ensure specializations of out_archetype have the intended properties
STATIC_ASSERT(!indirectly_writable<out_archetype<0, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<0, 3>, value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<0, 3>, value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<0, 3>, const value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<0, 3>, const value_type<3>&>);
static_assert(!indirectly_writable<out_archetype<0, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<0, 3>, value_type<3>&>);
static_assert(indirectly_writable<out_archetype<0, 3>, value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<0, 3>, const value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<0, 3>, const value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<1, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(!indirectly_writable<out_archetype<1, 3>, value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<1, 3>, value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<1, 3>, const value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<1, 3>, const value_type<3>&>);
static_assert(indirectly_writable<out_archetype<1, 3>, simple_reference<value_type<3>>>);
static_assert(!indirectly_writable<out_archetype<1, 3>, value_type<3>&>);
static_assert(indirectly_writable<out_archetype<1, 3>, value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<1, 3>, const value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<1, 3>, const value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, value_type<3>&>);
STATIC_ASSERT(!indirectly_writable<out_archetype<2, 3>, value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, const value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<2, 3>, const value_type<3>&>);
static_assert(indirectly_writable<out_archetype<2, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<2, 3>, value_type<3>&>);
static_assert(!indirectly_writable<out_archetype<2, 3>, value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<2, 3>, const value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<2, 3>, const value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<3, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<3, 3>, value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<3, 3>, value_type<3>&&>);
STATIC_ASSERT(!indirectly_writable<out_archetype<3, 3>, const value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<3, 3>, const value_type<3>&>);
static_assert(indirectly_writable<out_archetype<3, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<3, 3>, value_type<3>&>);
static_assert(indirectly_writable<out_archetype<3, 3>, value_type<3>&&>);
static_assert(!indirectly_writable<out_archetype<3, 3>, const value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<3, 3>, const value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<4, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<4, 3>, value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<4, 3>, value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<4, 3>, const value_type<3>&&>);
STATIC_ASSERT(!indirectly_writable<out_archetype<4, 3>, const value_type<3>&>);
static_assert(indirectly_writable<out_archetype<4, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<4, 3>, value_type<3>&>);
static_assert(indirectly_writable<out_archetype<4, 3>, value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<4, 3>, const value_type<3>&&>);
static_assert(!indirectly_writable<out_archetype<4, 3>, const value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<5, 3>, simple_reference<value_type<3>>>);
STATIC_ASSERT(indirectly_writable<out_archetype<5, 3>, value_type<3>&>);
STATIC_ASSERT(indirectly_writable<out_archetype<5, 3>, value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<5, 3>, const value_type<3>&&>);
STATIC_ASSERT(indirectly_writable<out_archetype<5, 3>, const value_type<3>&>);
static_assert(indirectly_writable<out_archetype<5, 3>, simple_reference<value_type<3>>>);
static_assert(indirectly_writable<out_archetype<5, 3>, value_type<3>&>);
static_assert(indirectly_writable<out_archetype<5, 3>, value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<5, 3>, const value_type<3>&&>);
static_assert(indirectly_writable<out_archetype<5, 3>, const value_type<3>&>);
// Validate indirectly_copyable
STATIC_ASSERT(!indirectly_copyable<simple_iter_archetype<0, value_type<3>>, out_archetype<1, 3>>);
STATIC_ASSERT(!indirectly_copyable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
STATIC_ASSERT(indirectly_copyable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
static_assert(!indirectly_copyable<simple_iter_archetype<0, value_type<3>>, out_archetype<1, 3>>);
static_assert(!indirectly_copyable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
static_assert(indirectly_copyable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
// Validate indirectly_copyable_storable
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<0, value_type<3>>, out_archetype<5, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<2, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<3, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<4, 3>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<0>>, out_archetype<5, 0>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<1>>, out_archetype<5, 1>>);
STATIC_ASSERT(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<2>>, out_archetype<5, 2>>);
STATIC_ASSERT(indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<5, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<0, value_type<3>>, out_archetype<5, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<0, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<1, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<2, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<3, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<4, 3>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<0>>, out_archetype<5, 0>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<1>>, out_archetype<5, 1>>);
static_assert(!indirectly_copyable_storable<simple_iter_archetype<1, value_type<2>>, out_archetype<5, 2>>);
static_assert(indirectly_copyable_storable<simple_iter_archetype<1, value_type<3>>, out_archetype<5, 3>>);
} // namespace indirectly_copyable_test
namespace indirectly_swappable_test {
@ -447,35 +445,35 @@ namespace indirectly_swappable_test {
// active (i.e., in permissive mode).
template <bool IsPermissive>
constexpr bool compile_only() {
STATIC_ASSERT(!indirectly_readable<archetype<0>>); // <0> is not indirectly_readable
STATIC_ASSERT(indirectly_readable<archetype<1>>); // <1+> is indirectly_readable
STATIC_ASSERT(indirectly_readable<archetype<2>>);
STATIC_ASSERT(indirectly_readable<archetype<3>>);
STATIC_ASSERT(indirectly_readable<archetype<4>>);
static_assert(!indirectly_readable<archetype<0>>); // <0> is not indirectly_readable
static_assert(indirectly_readable<archetype<1>>); // <1+> is indirectly_readable
static_assert(indirectly_readable<archetype<2>>);
static_assert(indirectly_readable<archetype<3>>);
static_assert(indirectly_readable<archetype<4>>);
STATIC_ASSERT(!indirectly_swappable<archetype<0>, archetype<0>>); // <0> is (still) not indirectly_readable
static_assert(!indirectly_swappable<archetype<0>, archetype<0>>); // <0> is (still) not indirectly_readable
if constexpr (!IsPermissive) {
STATIC_ASSERT(!indirectly_swappable<archetype<1>, archetype<1>>); // <1> is not self-indirectly_swappable
static_assert(!indirectly_swappable<archetype<1>, archetype<1>>); // <1> is not self-indirectly_swappable
}
STATIC_ASSERT(indirectly_swappable<archetype<2>, archetype<2>>); // <2+> is self-indirectly_swappable
STATIC_ASSERT(indirectly_swappable<archetype<3>, archetype<3>>);
STATIC_ASSERT(indirectly_swappable<archetype<4>, archetype<4>>);
static_assert(indirectly_swappable<archetype<2>, archetype<2>>); // <2+> is self-indirectly_swappable
static_assert(indirectly_swappable<archetype<3>, archetype<3>>);
static_assert(indirectly_swappable<archetype<4>, archetype<4>>);
STATIC_ASSERT(!indirectly_swappable<archetype<0>, archetype<4>>); // <0> is not indirectly_readable
STATIC_ASSERT(!indirectly_swappable<archetype<4>, archetype<0>>); // <0> is not indirectly_readable
static_assert(!indirectly_swappable<archetype<0>, archetype<4>>); // <0> is not indirectly_readable
static_assert(!indirectly_swappable<archetype<4>, archetype<0>>); // <0> is not indirectly_readable
if constexpr (!IsPermissive) {
STATIC_ASSERT(!indirectly_swappable<archetype<1>, archetype<4>>); // <1> is not self-indirectly_swappable
STATIC_ASSERT(!indirectly_swappable<archetype<4>, archetype<1>>); // <1> is not self-indirectly_swappable
static_assert(!indirectly_swappable<archetype<1>, archetype<4>>); // <1> is not self-indirectly_swappable
static_assert(!indirectly_swappable<archetype<4>, archetype<1>>); // <1> is not self-indirectly_swappable
}
STATIC_ASSERT(!indirectly_swappable<archetype<2>, archetype<4>>); // <2> & <4> aren't cross-indirectly_swappable
STATIC_ASSERT(!indirectly_swappable<archetype<4>, archetype<2>>); // <2> & <4> aren't cross-indirectly_swappable
static_assert(!indirectly_swappable<archetype<2>, archetype<4>>); // <2> & <4> aren't cross-indirectly_swappable
static_assert(!indirectly_swappable<archetype<4>, archetype<2>>); // <2> & <4> aren't cross-indirectly_swappable
STATIC_ASSERT(indirectly_swappable<archetype<3>, archetype<4>>);
STATIC_ASSERT(indirectly_swappable<archetype<4>, archetype<3>>);
static_assert(indirectly_swappable<archetype<3>, archetype<4>>);
static_assert(indirectly_swappable<archetype<4>, archetype<3>>);
return true;
}
STATIC_ASSERT(compile_only<is_permissive>());
static_assert(compile_only<is_permissive>());
} // namespace indirectly_swappable_test
namespace indirectly_comparable_test {
@ -503,16 +501,16 @@ namespace indirectly_comparable_test {
// clang-format on
};
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<0>, Proj, Proj>);
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<1>, Proj, Proj>);
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<0>, simple_iter_archetype<1>, Fn<2>, Proj, Proj>);
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<0>, Fn<2>, Proj, Proj>);
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, BadProj, Proj>);
STATIC_ASSERT(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, Proj, BadProj>);
STATIC_ASSERT(indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, Proj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<0>, Proj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<1>, Proj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<0>, simple_iter_archetype<1>, Fn<2>, Proj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<0>, Fn<2>, Proj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, BadProj, Proj>);
static_assert(!indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, Proj, BadProj>);
static_assert(indirectly_comparable<simple_iter_archetype<1>, simple_iter_archetype<1>, Fn<2>, Proj, Proj>);
using Projected = std::projected<simple_iter_archetype<1>, Proj>;
STATIC_ASSERT(std::same_as<std::indirect_result_t<Fn<2>, Projected, Projected>, void*>);
static_assert(std::same_as<std::indirect_result_t<Fn<2>, Projected, Projected>, void*>);
} // namespace indirectly_comparable_test
namespace dangling_test {
@ -520,24 +518,24 @@ namespace dangling_test {
using ranges::dangling, ranges::borrowed_iterator_t, ranges::borrowed_subrange_t;
using std::is_nothrow_constructible_v, std::same_as;
STATIC_ASSERT(std::is_class_v<dangling>);
STATIC_ASSERT(std::semiregular<dangling>);
STATIC_ASSERT(std::is_trivially_default_constructible_v<dangling>);
static_assert(std::is_class_v<dangling>);
static_assert(std::semiregular<dangling>);
static_assert(std::is_trivially_default_constructible_v<dangling>);
// dangling is constructible from any sequence of arguments without throwing
STATIC_ASSERT(is_nothrow_constructible_v<dangling>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, int>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, int*>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, int[42]>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, int (*)()>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, const int (*)[42]>);
STATIC_ASSERT(is_nothrow_constructible_v<dangling, int, int*, int[42], int (*)(), const int (*)[42]>);
static_assert(is_nothrow_constructible_v<dangling>);
static_assert(is_nothrow_constructible_v<dangling, int>);
static_assert(is_nothrow_constructible_v<dangling, int*>);
static_assert(is_nothrow_constructible_v<dangling, int[42]>);
static_assert(is_nothrow_constructible_v<dangling, int (*)()>);
static_assert(is_nothrow_constructible_v<dangling, const int (*)[42]>);
static_assert(is_nothrow_constructible_v<dangling, int, int*, int[42], int (*)(), const int (*)[42]>);
STATIC_ASSERT(same_as<borrowed_iterator_t<borrowed<false>>, dangling>);
STATIC_ASSERT(same_as<borrowed_iterator_t<borrowed<true>>, int*>);
static_assert(same_as<borrowed_iterator_t<borrowed<false>>, dangling>);
static_assert(same_as<borrowed_iterator_t<borrowed<true>>, int*>);
STATIC_ASSERT(same_as<borrowed_subrange_t<borrowed<false>>, dangling>);
STATIC_ASSERT(same_as<borrowed_subrange_t<borrowed<true>>, ranges::subrange<int*>>);
static_assert(same_as<borrowed_subrange_t<borrowed<false>>, dangling>);
static_assert(same_as<borrowed_subrange_t<borrowed<true>>, ranges::subrange<int*>>);
} // namespace dangling_test
namespace result_test {
@ -547,22 +545,22 @@ namespace result_test {
// Validate the result types are:
// * aggregates
STATIC_ASSERT(is_aggregate_v<in_found_result<int>>);
STATIC_ASSERT(is_aggregate_v<in_fun_result<int, int>>);
STATIC_ASSERT(is_aggregate_v<in_in_result<int, int>>);
STATIC_ASSERT(is_aggregate_v<in_out_result<int, int>>);
STATIC_ASSERT(is_aggregate_v<in_in_out_result<int, int, int>>);
STATIC_ASSERT(is_aggregate_v<in_out_out_result<int, int, int>>);
STATIC_ASSERT(is_aggregate_v<min_max_result<int>>);
static_assert(is_aggregate_v<in_found_result<int>>);
static_assert(is_aggregate_v<in_fun_result<int, int>>);
static_assert(is_aggregate_v<in_in_result<int, int>>);
static_assert(is_aggregate_v<in_out_result<int, int>>);
static_assert(is_aggregate_v<in_in_out_result<int, int, int>>);
static_assert(is_aggregate_v<in_out_out_result<int, int, int>>);
static_assert(is_aggregate_v<min_max_result<int>>);
// * trivial when parameter types are trivial
STATIC_ASSERT(is_trivial_v<in_found_result<int>>);
STATIC_ASSERT(is_trivial_v<in_fun_result<int, int>>);
STATIC_ASSERT(is_trivial_v<in_in_result<int, int>>);
STATIC_ASSERT(is_trivial_v<in_out_result<int, int>>);
STATIC_ASSERT(is_trivial_v<in_in_out_result<int, int, int>>);
STATIC_ASSERT(is_trivial_v<in_out_out_result<int, int, int>>);
STATIC_ASSERT(is_trivial_v<min_max_result<int>>);
static_assert(is_trivial_v<in_found_result<int>>);
static_assert(is_trivial_v<in_fun_result<int, int>>);
static_assert(is_trivial_v<in_in_result<int, int>>);
static_assert(is_trivial_v<in_out_result<int, int>>);
static_assert(is_trivial_v<in_in_out_result<int, int, int>>);
static_assert(is_trivial_v<in_out_out_result<int, int, int>>);
static_assert(is_trivial_v<min_max_result<int>>);
// * usable with structured bindings
constexpr bool test_bindings_in_found_result() {
@ -587,13 +585,13 @@ namespace result_test {
return true;
}
STATIC_ASSERT(test_bindings_in_found_result());
STATIC_ASSERT(test_bindings_2<in_fun_result<int, int>>());
STATIC_ASSERT(test_bindings_2<in_in_result<int, int>>());
STATIC_ASSERT(test_bindings_2<in_out_result<int, int>>());
STATIC_ASSERT(test_bindings_3<in_in_out_result<int, int, int>>());
STATIC_ASSERT(test_bindings_3<in_out_out_result<int, int, int>>());
STATIC_ASSERT(test_bindings_2<min_max_result<int>>());
static_assert(test_bindings_in_found_result());
static_assert(test_bindings_2<in_fun_result<int, int>>());
static_assert(test_bindings_2<in_in_result<int, int>>());
static_assert(test_bindings_2<in_out_result<int, int>>());
static_assert(test_bindings_3<in_in_out_result<int, int, int>>());
static_assert(test_bindings_3<in_out_out_result<int, int, int>>());
static_assert(test_bindings_2<min_max_result<int>>());
// * appropriately lvalue and rvalue inter-specialization convertible
template <class T>
@ -604,8 +602,8 @@ namespace result_test {
using CFI = convertible_from<int>;
constexpr bool test_convertible_in_found_result() {
STATIC_ASSERT(!is_convertible_v<in_found_result<int> const&, in_found_result<CFI>>);
STATIC_ASSERT(is_convertible_v<in_found_result<int>, in_found_result<CFI>>);
static_assert(!is_convertible_v<in_found_result<int> const&, in_found_result<CFI>>);
static_assert(is_convertible_v<in_found_result<int>, in_found_result<CFI>>);
in_found_result<int> a{42, true};
{
in_found_result<long> b = std::as_const(a);
@ -621,10 +619,10 @@ namespace result_test {
}
return true;
}
STATIC_ASSERT(test_convertible_in_found_result());
static_assert(test_convertible_in_found_result());
constexpr bool test_convertible_min_max_result() {
STATIC_ASSERT(!is_convertible_v<min_max_result<int> const&, min_max_result<CFI>>);
STATIC_ASSERT(is_convertible_v<min_max_result<int>, min_max_result<CFI>>);
static_assert(!is_convertible_v<min_max_result<int> const&, min_max_result<CFI>>);
static_assert(is_convertible_v<min_max_result<int>, min_max_result<CFI>>);
min_max_result<int> a{13, 42};
{
min_max_result<long> b = std::as_const(a);
@ -640,12 +638,12 @@ namespace result_test {
}
return true;
}
STATIC_ASSERT(test_convertible_min_max_result());
static_assert(test_convertible_min_max_result());
template <template <class, class> class R>
constexpr bool test_convertible_2() {
STATIC_ASSERT(!is_convertible_v<R<int, int> const&, R<CFI, CFI>>);
STATIC_ASSERT(is_convertible_v<R<int, int>, R<CFI, CFI>>);
static_assert(!is_convertible_v<R<int, int> const&, R<CFI, CFI>>);
static_assert(is_convertible_v<R<int, int>, R<CFI, CFI>>);
R<int, int> a{13, 42};
{
R<long, long> b = std::as_const(a);
@ -661,14 +659,14 @@ namespace result_test {
}
return true;
}
STATIC_ASSERT(test_convertible_2<in_fun_result>());
STATIC_ASSERT(test_convertible_2<in_in_result>());
STATIC_ASSERT(test_convertible_2<in_out_result>());
static_assert(test_convertible_2<in_fun_result>());
static_assert(test_convertible_2<in_in_result>());
static_assert(test_convertible_2<in_out_result>());
template <template <class, class, class> class R>
constexpr bool test_convertible_3() {
STATIC_ASSERT(!is_convertible_v<R<int, int, int> const&, R<CFI, CFI, CFI>>);
STATIC_ASSERT(is_convertible_v<R<int, int, int>, R<CFI, CFI, CFI>>);
static_assert(!is_convertible_v<R<int, int, int> const&, R<CFI, CFI, CFI>>);
static_assert(is_convertible_v<R<int, int, int>, R<CFI, CFI, CFI>>);
R<int, int, int> a{13, 42, 1729};
{
R<long, long, long> b = std::as_const(a);
@ -686,8 +684,8 @@ namespace result_test {
}
return true;
}
STATIC_ASSERT(test_convertible_3<in_in_out_result>());
STATIC_ASSERT(test_convertible_3<in_out_out_result>());
static_assert(test_convertible_3<in_in_out_result>());
static_assert(test_convertible_3<in_out_out_result>());
} // namespace result_test
namespace permutable_test {
@ -731,22 +729,22 @@ namespace permutable_test {
// [iterator.cust.swap]/4.3. permutable requires indirectly_swappable<T, T> only to forbid a user type from
// defining an iter_swap overload that doesn't meet the semantic requirements.
};
STATIC_ASSERT(input_iterator<archetype<0>>);
STATIC_ASSERT(!forward_iterator<archetype<0>>);
STATIC_ASSERT(indirectly_movable_storable<archetype<0>, archetype<0>>);
STATIC_ASSERT(indirectly_swappable<archetype<0>, archetype<0>>);
static_assert(input_iterator<archetype<0>>);
static_assert(!forward_iterator<archetype<0>>);
static_assert(indirectly_movable_storable<archetype<0>, archetype<0>>);
static_assert(indirectly_swappable<archetype<0>, archetype<0>>);
STATIC_ASSERT(forward_iterator<archetype<1>>);
STATIC_ASSERT(!indirectly_movable_storable<archetype<1>, archetype<1>>);
STATIC_ASSERT(indirectly_swappable<archetype<1>, archetype<1>>);
static_assert(forward_iterator<archetype<1>>);
static_assert(!indirectly_movable_storable<archetype<1>, archetype<1>>);
static_assert(indirectly_swappable<archetype<1>, archetype<1>>);
STATIC_ASSERT(forward_iterator<archetype<2>>);
STATIC_ASSERT(indirectly_movable_storable<archetype<2>, archetype<2>>);
STATIC_ASSERT(indirectly_swappable<archetype<2>, archetype<2>>);
static_assert(forward_iterator<archetype<2>>);
static_assert(indirectly_movable_storable<archetype<2>, archetype<2>>);
static_assert(indirectly_swappable<archetype<2>, archetype<2>>);
STATIC_ASSERT(!permutable<archetype<0>>);
STATIC_ASSERT(!permutable<archetype<1>>);
STATIC_ASSERT(permutable<archetype<2>>);
static_assert(!permutable<archetype<0>>);
static_assert(!permutable<archetype<1>>);
static_assert(permutable<archetype<2>>);
} // namespace permutable_test
namespace mergeable_test {
@ -805,88 +803,88 @@ namespace mergeable_test {
{
using Bad_I1 = readable_archetype<int, readable_status::not_input_iter>;
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!input_iterator<Bad_I1>);
static_assert(!input_iterator<Bad_I1>);
#endif // ^^^ no workaround ^^^
STATIC_ASSERT(input_iterator<I2>);
STATIC_ASSERT(weakly_incrementable<O>);
STATIC_ASSERT(indirectly_copyable<Bad_I1, O>);
STATIC_ASSERT(indirectly_copyable<I2, O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<Bad_I1, Pj1>, projected<I2, Pj2>>);
static_assert(input_iterator<I2>);
static_assert(weakly_incrementable<O>);
static_assert(indirectly_copyable<Bad_I1, O>);
static_assert(indirectly_copyable<I2, O>);
static_assert(indirect_strict_weak_order<Pr, projected<Bad_I1, Pj1>, projected<I2, Pj2>>);
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!mergeable<Bad_I1, I2, O, Pr, Pj1, Pj2>);
static_assert(!mergeable<Bad_I1, I2, O, Pr, Pj1, Pj2>);
#endif // ^^^ no workaround ^^^
}
{
using Bad_I2 = readable_archetype<long, readable_status::not_input_iter>;
STATIC_ASSERT(input_iterator<I1>);
static_assert(input_iterator<I1>);
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!input_iterator<Bad_I2>);
static_assert(!input_iterator<Bad_I2>);
#endif // ^^^ no workaround ^^^
STATIC_ASSERT(weakly_incrementable<O>);
STATIC_ASSERT(indirectly_copyable<I1, O>);
STATIC_ASSERT(indirectly_copyable<Bad_I2, O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<Bad_I2, Pj2>>);
static_assert(weakly_incrementable<O>);
static_assert(indirectly_copyable<I1, O>);
static_assert(indirectly_copyable<Bad_I2, O>);
static_assert(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<Bad_I2, Pj2>>);
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!mergeable<I1, Bad_I2, O, Pr, Pj1, Pj2>);
static_assert(!mergeable<I1, Bad_I2, O, Pr, Pj1, Pj2>);
#endif // ^^^ no workaround ^^^
}
{
using Bad_O = writable_archetype<writable_status::not_weakly_incrementable>;
STATIC_ASSERT(input_iterator<I1>);
STATIC_ASSERT(input_iterator<I2>);
static_assert(input_iterator<I1>);
static_assert(input_iterator<I2>);
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!weakly_incrementable<Bad_O>);
static_assert(!weakly_incrementable<Bad_O>);
#endif // ^^^ no workaround ^^^
STATIC_ASSERT(indirectly_copyable<I1, Bad_O>);
STATIC_ASSERT(indirectly_copyable<I2, Bad_O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
static_assert(indirectly_copyable<I1, Bad_O>);
static_assert(indirectly_copyable<I2, Bad_O>);
static_assert(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
#ifndef _M_CEE // TRANSITION, VSO-1665670
STATIC_ASSERT(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
static_assert(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
#endif // ^^^ no workaround ^^^
}
{
using Bad_O = writable_archetype<writable_status::not_ind_copy_int>;
STATIC_ASSERT(input_iterator<I1>);
STATIC_ASSERT(input_iterator<I2>);
STATIC_ASSERT(weakly_incrementable<Bad_O>);
STATIC_ASSERT(!indirectly_copyable<I1, Bad_O>);
STATIC_ASSERT(indirectly_copyable<I2, Bad_O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
STATIC_ASSERT(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
static_assert(input_iterator<I1>);
static_assert(input_iterator<I2>);
static_assert(weakly_incrementable<Bad_O>);
static_assert(!indirectly_copyable<I1, Bad_O>);
static_assert(indirectly_copyable<I2, Bad_O>);
static_assert(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
static_assert(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
}
{
using Bad_O = writable_archetype<writable_status::not_ind_copy_long>;
STATIC_ASSERT(input_iterator<I1>);
STATIC_ASSERT(input_iterator<I2>);
STATIC_ASSERT(weakly_incrementable<Bad_O>);
STATIC_ASSERT(indirectly_copyable<I1, Bad_O>);
STATIC_ASSERT(!indirectly_copyable<I2, Bad_O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
STATIC_ASSERT(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
static_assert(input_iterator<I1>);
static_assert(input_iterator<I2>);
static_assert(weakly_incrementable<Bad_O>);
static_assert(indirectly_copyable<I1, Bad_O>);
static_assert(!indirectly_copyable<I2, Bad_O>);
static_assert(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
static_assert(!mergeable<I1, I2, Bad_O, Pr, Pj1, Pj2>);
}
{
using Bad_Pr = int;
STATIC_ASSERT(input_iterator<I1>);
STATIC_ASSERT(input_iterator<I2>);
STATIC_ASSERT(weakly_incrementable<O>);
STATIC_ASSERT(indirectly_copyable<I1, O>);
STATIC_ASSERT(indirectly_copyable<I2, O>);
STATIC_ASSERT(!indirect_strict_weak_order<Bad_Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
STATIC_ASSERT(!mergeable<I1, I2, O, Bad_Pr, Pj1, Pj2>);
static_assert(input_iterator<I1>);
static_assert(input_iterator<I2>);
static_assert(weakly_incrementable<O>);
static_assert(indirectly_copyable<I1, O>);
static_assert(indirectly_copyable<I2, O>);
static_assert(!indirect_strict_weak_order<Bad_Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
static_assert(!mergeable<I1, I2, O, Bad_Pr, Pj1, Pj2>);
}
STATIC_ASSERT(input_iterator<I1>);
STATIC_ASSERT(input_iterator<I2>);
STATIC_ASSERT(weakly_incrementable<O>);
STATIC_ASSERT(indirectly_copyable<I1, O>);
STATIC_ASSERT(indirectly_copyable<I2, O>);
STATIC_ASSERT(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
STATIC_ASSERT(mergeable<I1, I2, O, Pr, Pj1, Pj2>);
static_assert(input_iterator<I1>);
static_assert(input_iterator<I2>);
static_assert(weakly_incrementable<O>);
static_assert(indirectly_copyable<I1, O>);
static_assert(indirectly_copyable<I2, O>);
static_assert(indirect_strict_weak_order<Pr, projected<I1, Pj1>, projected<I2, Pj2>>);
static_assert(mergeable<I1, I2, O, Pr, Pj1, Pj2>);
}
} // namespace mergeable_test
@ -899,27 +897,27 @@ namespace sortable_test {
using I = int const*; // not permutable
using C = less;
using P = identity;
STATIC_ASSERT(!permutable<I>);
STATIC_ASSERT(indirect_strict_weak_order<C, projected<I, P>>);
STATIC_ASSERT(!sortable<I, C, P>);
static_assert(!permutable<I>);
static_assert(indirect_strict_weak_order<C, projected<I, P>>);
static_assert(!sortable<I, C, P>);
}
{
using I = int*;
using C = void; // not an indirect_strict_weak_order
using P = identity;
STATIC_ASSERT(permutable<I>);
STATIC_ASSERT(!indirect_strict_weak_order<C, projected<I, P>>);
STATIC_ASSERT(!sortable<I, C, P>);
static_assert(permutable<I>);
static_assert(!indirect_strict_weak_order<C, projected<I, P>>);
static_assert(!sortable<I, C, P>);
}
{
using I = int*;
using C = less;
using P = identity;
STATIC_ASSERT(permutable<I>);
STATIC_ASSERT(indirect_strict_weak_order<C, projected<I, P>>);
STATIC_ASSERT(sortable<I, C, P>);
static_assert(permutable<I>);
static_assert(indirect_strict_weak_order<C, projected<I, P>>);
static_assert(sortable<I, C, P>);
}
}
} // namespace sortable_test
@ -950,7 +948,7 @@ namespace gh_1089 {
};
STATIC_ASSERT(sizeof(&Derived1::purr) > sizeof(void*)); // NB: relies on non-portable platform properties
static_assert(sizeof(&Derived1::purr) > sizeof(void*)); // NB: relies on non-portable platform properties
Derived1 a[2];
MostDerived b[3];
@ -963,13 +961,13 @@ namespace gh_1089 {
using PMD_Cat = int Cat::*;
// Quantum effects: we must observe the size before defining Cat or it will become smaller.
STATIC_ASSERT(sizeof(PMD_Cat) > sizeof(void*));
static_assert(sizeof(PMD_Cat) > sizeof(void*));
struct Cat {
int x = 42;
};
STATIC_ASSERT(sizeof(&Cat::x) > sizeof(void*)); // NB: relies on non-portable platform properties
static_assert(sizeof(&Cat::x) > sizeof(void*)); // NB: relies on non-portable platform properties
Cat cats[42];
@ -1007,36 +1005,36 @@ namespace special_memory_concepts {
// clang-format on
};
// Verify iterator_archetype
STATIC_ASSERT(!input_iterator<iterator_archetype<iterator_status::not_input>>);
STATIC_ASSERT(input_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
STATIC_ASSERT(input_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
STATIC_ASSERT(input_iterator<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(!forward_iterator<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(forward_iterator<iterator_archetype<iterator_status::forward>>);
static_assert(!input_iterator<iterator_archetype<iterator_status::not_input>>);
static_assert(input_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
static_assert(input_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
static_assert(input_iterator<iterator_archetype<iterator_status::input>>);
static_assert(!forward_iterator<iterator_archetype<iterator_status::input>>);
static_assert(forward_iterator<iterator_archetype<iterator_status::forward>>);
template <class I>
constexpr bool has_lvalue_reference = std::is_lvalue_reference_v<std::iter_reference_t<I>>;
STATIC_ASSERT(has_lvalue_reference<iterator_archetype<iterator_status::not_input>>);
STATIC_ASSERT(!has_lvalue_reference<iterator_archetype<iterator_status::not_lvalue_reference>>);
STATIC_ASSERT(has_lvalue_reference<iterator_archetype<iterator_status::different_reference_and_value>>);
STATIC_ASSERT(has_lvalue_reference<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(has_lvalue_reference<iterator_archetype<iterator_status::forward>>);
static_assert(has_lvalue_reference<iterator_archetype<iterator_status::not_input>>);
static_assert(!has_lvalue_reference<iterator_archetype<iterator_status::not_lvalue_reference>>);
static_assert(has_lvalue_reference<iterator_archetype<iterator_status::different_reference_and_value>>);
static_assert(has_lvalue_reference<iterator_archetype<iterator_status::input>>);
static_assert(has_lvalue_reference<iterator_archetype<iterator_status::forward>>);
template <class I>
constexpr bool same_reference_value =
std::same_as<std::remove_cvref_t<std::iter_reference_t<I>>, std::iter_value_t<I>>;
STATIC_ASSERT(same_reference_value<iterator_archetype<iterator_status::not_input>>);
STATIC_ASSERT(same_reference_value<iterator_archetype<iterator_status::not_lvalue_reference>>);
STATIC_ASSERT(!same_reference_value<iterator_archetype<iterator_status::different_reference_and_value>>);
STATIC_ASSERT(same_reference_value<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(same_reference_value<iterator_archetype<iterator_status::forward>>);
static_assert(same_reference_value<iterator_archetype<iterator_status::not_input>>);
static_assert(same_reference_value<iterator_archetype<iterator_status::not_lvalue_reference>>);
static_assert(!same_reference_value<iterator_archetype<iterator_status::different_reference_and_value>>);
static_assert(same_reference_value<iterator_archetype<iterator_status::input>>);
static_assert(same_reference_value<iterator_archetype<iterator_status::forward>>);
// Validate _No_throw_input_iterator
STATIC_ASSERT(!_No_throw_input_iterator<iterator_archetype<iterator_status::not_input>>);
STATIC_ASSERT(!_No_throw_input_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
STATIC_ASSERT(!_No_throw_input_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
STATIC_ASSERT(_No_throw_input_iterator<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(_No_throw_input_iterator<iterator_archetype<iterator_status::forward>>);
static_assert(!_No_throw_input_iterator<iterator_archetype<iterator_status::not_input>>);
static_assert(!_No_throw_input_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
static_assert(!_No_throw_input_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
static_assert(_No_throw_input_iterator<iterator_archetype<iterator_status::input>>);
static_assert(_No_throw_input_iterator<iterator_archetype<iterator_status::forward>>);
enum class sentinel_status : int { no, yes };
@ -1048,25 +1046,25 @@ namespace special_memory_concepts {
// clang-format on
};
// Verify sentinel_archetype
STATIC_ASSERT(!sentinel_for<sentinel_archetype<sentinel_status::no>, iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(sentinel_for<sentinel_archetype<sentinel_status::yes>, iterator_archetype<iterator_status::input>>);
static_assert(!sentinel_for<sentinel_archetype<sentinel_status::no>, iterator_archetype<iterator_status::input>>);
static_assert(sentinel_for<sentinel_archetype<sentinel_status::yes>, iterator_archetype<iterator_status::input>>);
// Validate _No_throw_sentinel_for
STATIC_ASSERT(
static_assert(
!_No_throw_sentinel_for<sentinel_archetype<sentinel_status::no>, iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(
static_assert(
_No_throw_sentinel_for<sentinel_archetype<sentinel_status::yes>, iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(!_No_throw_sentinel_for<iterator_archetype<iterator_status::input>,
static_assert(!_No_throw_sentinel_for<iterator_archetype<iterator_status::input>,
iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(_No_throw_sentinel_for<iterator_archetype<iterator_status::forward>,
static_assert(_No_throw_sentinel_for<iterator_archetype<iterator_status::forward>,
iterator_archetype<iterator_status::forward>>);
// Validate _No_throw_forward_iterator
STATIC_ASSERT(!_No_throw_forward_iterator<iterator_archetype<iterator_status::not_input>>);
STATIC_ASSERT(!_No_throw_forward_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
STATIC_ASSERT(!_No_throw_forward_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
STATIC_ASSERT(!_No_throw_forward_iterator<iterator_archetype<iterator_status::input>>);
STATIC_ASSERT(_No_throw_forward_iterator<iterator_archetype<iterator_status::forward>>);
static_assert(!_No_throw_forward_iterator<iterator_archetype<iterator_status::not_input>>);
static_assert(!_No_throw_forward_iterator<iterator_archetype<iterator_status::not_lvalue_reference>>);
static_assert(!_No_throw_forward_iterator<iterator_archetype<iterator_status::different_reference_and_value>>);
static_assert(!_No_throw_forward_iterator<iterator_archetype<iterator_status::input>>);
static_assert(_No_throw_forward_iterator<iterator_archetype<iterator_status::forward>>);
enum class range_status : int { not_range, not_input, input, forward };
@ -1084,21 +1082,21 @@ namespace special_memory_concepts {
Se end() const;
};
// Verify range_archetype
STATIC_ASSERT(!ranges::range<range_archetype<range_status::not_range>>);
STATIC_ASSERT(ranges::range<range_archetype<range_status::not_input>>);
STATIC_ASSERT(ranges::range<range_archetype<range_status::input>>);
STATIC_ASSERT(ranges::range<range_archetype<range_status::forward>>);
static_assert(!ranges::range<range_archetype<range_status::not_range>>);
static_assert(ranges::range<range_archetype<range_status::not_input>>);
static_assert(ranges::range<range_archetype<range_status::input>>);
static_assert(ranges::range<range_archetype<range_status::forward>>);
// Validate _No_throw_input_range; note that the distinction between range<R> and
// no-throw-sentinel-for<sentinel_t<R>, iterator_t<R>> is purely semantic, so we can't test them separately.
STATIC_ASSERT(!_No_throw_input_range<range_archetype<range_status::not_range>>);
STATIC_ASSERT(!_No_throw_input_range<range_archetype<range_status::not_input>>);
STATIC_ASSERT(_No_throw_input_range<range_archetype<range_status::input>>);
STATIC_ASSERT(_No_throw_input_range<range_archetype<range_status::forward>>);
static_assert(!_No_throw_input_range<range_archetype<range_status::not_range>>);
static_assert(!_No_throw_input_range<range_archetype<range_status::not_input>>);
static_assert(_No_throw_input_range<range_archetype<range_status::input>>);
static_assert(_No_throw_input_range<range_archetype<range_status::forward>>);
// Validate _No_throw_forward_range
STATIC_ASSERT(!_No_throw_forward_range<range_archetype<range_status::not_range>>);
STATIC_ASSERT(!_No_throw_forward_range<range_archetype<range_status::not_input>>);
STATIC_ASSERT(!_No_throw_forward_range<range_archetype<range_status::input>>);
STATIC_ASSERT(_No_throw_forward_range<range_archetype<range_status::forward>>);
static_assert(!_No_throw_forward_range<range_archetype<range_status::not_range>>);
static_assert(!_No_throw_forward_range<range_archetype<range_status::not_input>>);
static_assert(!_No_throw_forward_range<range_archetype<range_status::input>>);
static_assert(_No_throw_forward_range<range_archetype<range_status::forward>>);
} // namespace special_memory_concepts

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -26,16 +26,16 @@ struct instantiator {
int input[3] = {0, 1, 2};
{ // traits
STATIC_ASSERT(ranges::input_range<R> || ranges::output_range<R, const int&>);
STATIC_ASSERT(ranges::enable_borrowed_range<ref_view<R>>);
static_assert(ranges::input_range<R> || ranges::output_range<R, const int&>);
static_assert(ranges::enable_borrowed_range<ref_view<R>>);
}
{ // constructors and assignment operators
STATIC_ASSERT(!constructible_from<ref_view<R>, R>);
static_assert(!constructible_from<ref_view<R>, R>);
R wrapped_input{input};
ref_view<R> same_range{wrapped_input};
STATIC_ASSERT(is_nothrow_constructible_v<ref_view<R>, R&>);
static_assert(is_nothrow_constructible_v<ref_view<R>, R&>);
auto copy_constructed = same_range;
if constexpr (forward_range<R>) {
@ -71,7 +71,7 @@ struct instantiator {
same_as<R> auto& base_range = as_const(test_view).base();
assert(addressof(base_range) == addressof(wrapped_input));
STATIC_ASSERT(noexcept(as_const(test_view).base()));
static_assert(noexcept(as_const(test_view).base()));
}
{ // iterators
@ -79,11 +79,11 @@ struct instantiator {
ref_view<R> test_view{wrapped_input};
const same_as<ranges::iterator_t<R>> auto first = as_const(test_view).begin();
assert(first.peek() == input);
STATIC_ASSERT(noexcept(as_const(test_view).begin()) == noexcept(wrapped_input.begin()));
static_assert(noexcept(as_const(test_view).begin()) == noexcept(wrapped_input.begin()));
const same_as<ranges::sentinel_t<R>> auto last = as_const(test_view).end();
assert(last.peek() == end(input));
STATIC_ASSERT(noexcept(as_const(test_view).end()) == noexcept(wrapped_input.end()));
static_assert(noexcept(as_const(test_view).end()) == noexcept(wrapped_input.end()));
}
#if _HAS_CXX23
@ -107,7 +107,7 @@ struct instantiator {
#endif // _HAS_CXX23
{ // state
STATIC_ASSERT(can_size<ref_view<R>> == ranges::sized_range<R>);
static_assert(can_size<ref_view<R>> == ranges::sized_range<R>);
if constexpr (ranges::sized_range<R>) {
R wrapped_input{input};
ref_view<R> test_view{wrapped_input};
@ -115,10 +115,10 @@ struct instantiator {
const same_as<ranges::range_size_t<R>> auto ref_size = as_const(test_view).size();
assert(ref_size == size(wrapped_input));
STATIC_ASSERT(noexcept(as_const(test_view).size()) == noexcept(wrapped_input.size()));
static_assert(noexcept(as_const(test_view).size()) == noexcept(wrapped_input.size()));
}
STATIC_ASSERT(can_data<ref_view<R>> == ranges::contiguous_range<R>);
static_assert(can_data<ref_view<R>> == ranges::contiguous_range<R>);
if constexpr (ranges::contiguous_range<R>) {
R wrapped_input{input};
ref_view<R> test_view{wrapped_input};
@ -126,10 +126,10 @@ struct instantiator {
const same_as<int*> auto ref_data = as_const(test_view).data();
assert(ref_data == input);
STATIC_ASSERT(noexcept(as_const(test_view).data()) == noexcept(wrapped_input.data()));
static_assert(noexcept(as_const(test_view).data()) == noexcept(wrapped_input.data()));
}
STATIC_ASSERT(can_empty<ref_view<R>> == can_empty<R>);
static_assert(can_empty<ref_view<R>> == can_empty<R>);
if constexpr (can_empty<R>) {
R wrapped_input{input};
ref_view<R> test_view{wrapped_input};
@ -137,7 +137,7 @@ struct instantiator {
const same_as<bool> auto ref_empty = as_const(test_view).empty();
assert(!ref_empty);
STATIC_ASSERT(noexcept(as_const(test_view).empty()) == noexcept(ranges::empty(wrapped_input)));
static_assert(noexcept(as_const(test_view).empty()) == noexcept(ranges::empty(wrapped_input)));
R empty_range{span<int, 0>{}};
ref_view<R> empty_view{empty_range};
@ -148,12 +148,12 @@ struct instantiator {
{ // CTAD
span<const int, 3> spanInput{input};
ref_view span_view{spanInput};
STATIC_ASSERT(same_as<decltype(span_view), ref_view<span<const int, 3>>>);
static_assert(same_as<decltype(span_view), ref_view<span<const int, 3>>>);
}
}
};
int main() {
STATIC_ASSERT((test_inout<instantiator, int>(), true));
static_assert((test_inout<instantiator, int>(), true));
test_inout<instantiator, int>();
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -6,8 +6,6 @@
#include <range_algorithm_support.hpp>
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
using namespace std;
using test::CanCompare, test::CanDifference, test::WrappedState, test::ProxyRef, test::to_bool;
@ -19,185 +17,185 @@ constexpr bool iter_test() {
using I = iterator<Category, Element, Diff, Eq, Proxy, Wrapped>;
STATIC_ASSERT(default_initializable<I> == (Eq == CanCompare::yes));
STATIC_ASSERT(movable<I>);
static_assert(default_initializable<I> == (Eq == CanCompare::yes));
static_assert(movable<I>);
STATIC_ASSERT(!movable<Element> || indirectly_writable<I, Element>);
static_assert(!movable<Element> || indirectly_writable<I, Element>);
constexpr bool can_write = derived_from<Category, output_iterator_tag>
|| (derived_from<Category, forward_iterator_tag> && assignable_from<Element&, Element>);
STATIC_ASSERT(!can_write || output_iterator<I, Element>);
static_assert(!can_write || output_iterator<I, Element>);
STATIC_ASSERT(!derived_from<Category, input_iterator_tag> || input_iterator<I>);
STATIC_ASSERT(!derived_from<Category, forward_iterator_tag> || forward_iterator<I>);
STATIC_ASSERT(!derived_from<Category, bidirectional_iterator_tag> || bidirectional_iterator<I>);
STATIC_ASSERT(!derived_from<Category, random_access_iterator_tag> || random_access_iterator<I>);
STATIC_ASSERT(!derived_from<Category, contiguous_iterator_tag> || contiguous_iterator<I>);
static_assert(!derived_from<Category, input_iterator_tag> || input_iterator<I>);
static_assert(!derived_from<Category, forward_iterator_tag> || forward_iterator<I>);
static_assert(!derived_from<Category, bidirectional_iterator_tag> || bidirectional_iterator<I>);
static_assert(!derived_from<Category, random_access_iterator_tag> || random_access_iterator<I>);
static_assert(!derived_from<Category, contiguous_iterator_tag> || contiguous_iterator<I>);
using S = sentinel<Element, Wrapped>;
STATIC_ASSERT(sentinel_for<S, I>);
STATIC_ASSERT(!to_bool(Diff) || sized_sentinel_for<S, I>);
STATIC_ASSERT(!to_bool(Eq) || sentinel_for<I, I>);
STATIC_ASSERT(!to_bool(Eq) || !to_bool(Diff) || sized_sentinel_for<I, I>);
static_assert(sentinel_for<S, I>);
static_assert(!to_bool(Diff) || sized_sentinel_for<S, I>);
static_assert(!to_bool(Eq) || sentinel_for<I, I>);
static_assert(!to_bool(Eq) || !to_bool(Diff) || sized_sentinel_for<I, I>);
if constexpr (Wrapped == WrappedState::ignorant) {
STATIC_ASSERT(sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::wrapped>>);
STATIC_ASSERT(!sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::unwrapped>>);
static_assert(sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::wrapped>>);
static_assert(!sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::unwrapped>>);
STATIC_ASSERT(sentinel_for<sentinel<Element, WrappedState::wrapped>, I>);
STATIC_ASSERT(!sentinel_for<sentinel<Element, WrappedState::unwrapped>, I>);
static_assert(sentinel_for<sentinel<Element, WrappedState::wrapped>, I>);
static_assert(!sentinel_for<sentinel<Element, WrappedState::unwrapped>, I>);
STATIC_ASSERT(!_Unwrappable_v<I>);
STATIC_ASSERT(!_Unwrappable_v<S>);
static_assert(!_Unwrappable_v<I>);
static_assert(!_Unwrappable_v<S>);
} else if constexpr (Wrapped == WrappedState::wrapped) {
STATIC_ASSERT(sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::ignorant>>);
STATIC_ASSERT(!sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::unwrapped>>);
static_assert(sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::ignorant>>);
static_assert(!sentinel_for<S, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::unwrapped>>);
STATIC_ASSERT(sentinel_for<sentinel<Element, WrappedState::ignorant>, I>);
STATIC_ASSERT(!sentinel_for<sentinel<Element, WrappedState::unwrapped>, I>);
static_assert(sentinel_for<sentinel<Element, WrappedState::ignorant>, I>);
static_assert(!sentinel_for<sentinel<Element, WrappedState::unwrapped>, I>);
if constexpr (derived_from<Category, contiguous_iterator_tag>) {
STATIC_ASSERT(same_as<_Unwrapped_t<I>, Element*>);
static_assert(same_as<_Unwrapped_t<I>, Element*>);
} else {
STATIC_ASSERT(
static_assert(
same_as<_Unwrapped_t<I>, iterator<Category, Element, Diff, Eq, Proxy, WrappedState::unwrapped>>);
}
STATIC_ASSERT(same_as<_Unwrapped_t<S>, sentinel<Element, WrappedState::unwrapped>>);
static_assert(same_as<_Unwrapped_t<S>, sentinel<Element, WrappedState::unwrapped>>);
}
STATIC_ASSERT(convertible_to<I, typename I::Consterator>);
STATIC_ASSERT(!to_bool(Eq) || convertible_to<const I&, typename I::Consterator>);
static_assert(convertible_to<I, typename I::Consterator>);
static_assert(!to_bool(Eq) || convertible_to<const I&, typename I::Consterator>);
return true;
}
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<output_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::no, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::no, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<input_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(iter_test<forward_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<forward_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<forward_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes, WrappedState::wrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<bidirectional_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::yes,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
static_assert(iter_test<random_access_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::yes,
WrappedState::wrapped>());
STATIC_ASSERT(iter_test<contiguous_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<contiguous_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(
static_assert(
iter_test<contiguous_iterator_tag, int, CanDifference::no, CanCompare::yes, ProxyRef::no, WrappedState::wrapped>());
STATIC_ASSERT(iter_test<contiguous_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<contiguous_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::unwrapped>());
STATIC_ASSERT(iter_test<contiguous_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
static_assert(iter_test<contiguous_iterator_tag, int, CanDifference::yes, CanCompare::yes, ProxyRef::no,
WrappedState::wrapped>());
STATIC_ASSERT(
static_assert(
same_as<_Unwrapped_t<test::sentinel<int, WrappedState::wrapped>>, test::sentinel<int, WrappedState::unwrapped>>);
// Validate test::range
@ -215,238 +213,238 @@ constexpr bool range_test() {
using R = test::range<Category, Element, IsSized, Diff, IsCommon, Eq, Proxy>;
using I = ranges::iterator_t<R>;
using S = ranges::sentinel_t<R>;
STATIC_ASSERT(same_as<I, test::iterator<Category, Element, Diff, Eq, Proxy, WrappedState::wrapped>>);
static_assert(same_as<I, test::iterator<Category, Element, Diff, Eq, Proxy, WrappedState::wrapped>>);
STATIC_ASSERT(!derived_from<Category, output_iterator_tag> || ranges::output_range<R, Element>);
STATIC_ASSERT(!derived_from<Category, input_iterator_tag> || ranges::input_range<R>);
STATIC_ASSERT(!derived_from<Category, forward_iterator_tag> || ranges::forward_range<R>);
STATIC_ASSERT(!derived_from<Category, bidirectional_iterator_tag> || ranges::bidirectional_range<R>);
STATIC_ASSERT(!derived_from<Category, random_access_iterator_tag> || ranges::random_access_range<R>);
STATIC_ASSERT(!derived_from<Category, contiguous_iterator_tag> || ranges::contiguous_range<R>);
static_assert(!derived_from<Category, output_iterator_tag> || ranges::output_range<R, Element>);
static_assert(!derived_from<Category, input_iterator_tag> || ranges::input_range<R>);
static_assert(!derived_from<Category, forward_iterator_tag> || ranges::forward_range<R>);
static_assert(!derived_from<Category, bidirectional_iterator_tag> || ranges::bidirectional_range<R>);
static_assert(!derived_from<Category, random_access_iterator_tag> || ranges::random_access_range<R>);
static_assert(!derived_from<Category, contiguous_iterator_tag> || ranges::contiguous_range<R>);
if constexpr (to_bool(IsCommon)) {
STATIC_ASSERT(to_bool(Eq));
STATIC_ASSERT(ranges::common_range<R>);
static_assert(to_bool(Eq));
static_assert(ranges::common_range<R>);
} else {
STATIC_ASSERT(same_as<S, test::sentinel<Element, WrappedState::wrapped>>);
static_assert(same_as<S, test::sentinel<Element, WrappedState::wrapped>>);
}
STATIC_ASSERT(!to_bool(Eq) || sentinel_for<I, I>);
static_assert(!to_bool(Eq) || sentinel_for<I, I>);
constexpr bool is_sized = to_bool(IsSized) || (to_bool(Diff) && derived_from<Category, forward_iterator_tag>);
STATIC_ASSERT(ranges::sized_range<R> == is_sized);
static_assert(ranges::sized_range<R> == is_sized);
if constexpr (to_bool(IsSized)) {
STATIC_ASSERT(has_member_size<R>);
static_assert(has_member_size<R>);
}
return true;
}
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<output_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::no, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<input_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(range_test<forward_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<forward_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes, ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
static_assert(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(
static_assert(
range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes, ProxyRef::no>());
STATIC_ASSERT(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<forward_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::no, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::no, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<bidirectional_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<random_access_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::yes>());
STATIC_ASSERT(range_test<contiguous_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<contiguous_iterator_tag, int, Sized::no, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<contiguous_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<contiguous_iterator_tag, int, Sized::no, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<contiguous_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
static_assert(range_test<contiguous_iterator_tag, int, Sized::yes, CanDifference::yes, Common::no, CanCompare::yes,
ProxyRef::no>());
STATIC_ASSERT(range_test<contiguous_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
static_assert(range_test<contiguous_iterator_tag, int, Sized::yes, CanDifference::yes, Common::yes, CanCompare::yes,
ProxyRef::no>());
// Validate basic_borrowed_range
STATIC_ASSERT(ranges::input_range<basic_borrowed_range<int>>);
STATIC_ASSERT(!ranges::forward_range<basic_borrowed_range<int>>);
STATIC_ASSERT(!movable<basic_borrowed_range<int>>);
static_assert(ranges::input_range<basic_borrowed_range<int>>);
static_assert(!ranges::forward_range<basic_borrowed_range<int>>);
static_assert(!movable<basic_borrowed_range<int>>);
struct instantiate {
template <class Range1, class Range2>
static constexpr void call() {
STATIC_ASSERT(ranges::input_range<Range1>);
STATIC_ASSERT(same_as<ranges::range_value_t<Range1>, double>);
STATIC_ASSERT(indirectly_writable<ranges::iterator_t<Range1>, const double&>);
static_assert(ranges::input_range<Range1>);
static_assert(same_as<ranges::range_value_t<Range1>, double>);
static_assert(indirectly_writable<ranges::iterator_t<Range1>, const double&>);
STATIC_ASSERT(ranges::input_range<Range2>);
STATIC_ASSERT(same_as<ranges::range_value_t<Range2>, void*>);
STATIC_ASSERT(!indirectly_writable<ranges::iterator_t<Range2>, void*>);
static_assert(ranges::input_range<Range2>);
static_assert(same_as<ranges::range_value_t<Range2>, void*>);
static_assert(!indirectly_writable<ranges::iterator_t<Range2>, void*>);
}
};

Просмотреть файл

@ -343,10 +343,10 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
// Validate common_view::begin and common_view::end
STATIC_ASSERT(CanMemberBegin<R>);
STATIC_ASSERT(CanBegin<const R&> == range<const V>);
STATIC_ASSERT(CanMemberEnd<R>);
STATIC_ASSERT(CanEnd<const R&> == range<const V>);
static_assert(CanMemberBegin<R>);
static_assert(CanBegin<const R&> == range<const V>);
static_assert(CanMemberEnd<R>);
static_assert(CanEnd<const R&> == range<const V>);
if (!is_constant_evaluated()) {
non_literal_parts<V>(r, expected);
}

Просмотреть файл

@ -39,16 +39,16 @@ struct instantiator {
ranges::subrange;
int input[] = {13, 42, 1729, -1, -1};
STATIC_ASSERT(Countable<Iter>);
STATIC_ASSERT(Countable<const Iter&> == copy_constructible<Iter>);
static_assert(Countable<Iter>);
static_assert(Countable<const Iter&> == copy_constructible<Iter>);
auto result = ranges::views::counted(Iter{input}, convertible_difference<Iter>{3});
if constexpr (contiguous_iterator<Iter>) {
STATIC_ASSERT(same_as<decltype(result), span<remove_reference_t<iter_reference_t<Iter>>, dynamic_extent>>);
static_assert(same_as<decltype(result), span<remove_reference_t<iter_reference_t<Iter>>, dynamic_extent>>);
} else if constexpr (random_access_iterator<Iter>) {
STATIC_ASSERT(same_as<decltype(result), subrange<Iter, Iter>>);
static_assert(same_as<decltype(result), subrange<Iter, Iter>>);
} else {
STATIC_ASSERT(same_as<decltype(result), subrange<counted_iterator<Iter>, default_sentinel_t>>);
static_assert(same_as<decltype(result), subrange<counted_iterator<Iter>, default_sentinel_t>>);
}
assert(size(result) == 3);
if constexpr (input_iterator<Iter>) {
@ -58,6 +58,6 @@ struct instantiator {
};
int main() {
STATIC_ASSERT(with_writable_iterators<instantiator, int>::call());
static_assert(with_writable_iterators<instantiator, int>::call());
with_writable_iterators<instantiator, int>::call();
}

Просмотреть файл

@ -95,99 +95,99 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
using V = views::all_t<Rng>;
using M = mapped_t<Rng>;
STATIC_ASSERT(ranges::view<M>);
STATIC_ASSERT(common_range<M> == common_range<Rng>);
STATIC_ASSERT(input_range<M> == input_range<Rng>);
STATIC_ASSERT(forward_range<M> == forward_range<Rng>);
STATIC_ASSERT(bidirectional_range<M> == bidirectional_range<Rng>);
STATIC_ASSERT(random_access_range<M> == random_access_range<Rng>);
STATIC_ASSERT(contiguous_range<M> == contiguous_range<Rng>);
static_assert(ranges::view<M>);
static_assert(common_range<M> == common_range<Rng>);
static_assert(input_range<M> == input_range<Rng>);
static_assert(forward_range<M> == forward_range<Rng>);
static_assert(bidirectional_range<M> == bidirectional_range<Rng>);
static_assert(random_access_range<M> == random_access_range<Rng>);
static_assert(contiguous_range<M> == contiguous_range<Rng>);
// Validate range adaptor object and range adaptor closure
constexpr auto closure = views::drop(4);
// ... with lvalue argument
STATIC_ASSERT(CanViewDrop<Rng&> == (!is_view || copy_constructible<V>) );
static_assert(CanViewDrop<Rng&> == (!is_view || copy_constructible<V>) );
if constexpr (CanViewDrop<Rng&>) { // Validate lvalue
constexpr bool is_noexcept = !is_view || (is_nothrow_copy_constructible_v<V> && !is_subrange<V>);
STATIC_ASSERT(same_as<decltype(views::drop(rng, 4)), M>);
STATIC_ASSERT(noexcept(views::drop(rng, 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(rng, 4)), M>);
static_assert(noexcept(views::drop(rng, 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(rng | closure), M>);
STATIC_ASSERT(noexcept(rng | closure) == is_noexcept);
static_assert(same_as<decltype(rng | closure), M>);
static_assert(noexcept(rng | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(rng | pipeline), pipeline_t<Rng&>>);
STATIC_ASSERT(noexcept(rng | pipeline) == is_noexcept);
static_assert(same_as<decltype(rng | pipeline), pipeline_t<Rng&>>);
static_assert(noexcept(rng | pipeline) == is_noexcept);
}
// ... with const lvalue argument
STATIC_ASSERT(CanViewDrop<const remove_reference_t<Rng>&> == (!is_view || copy_constructible<V>) );
static_assert(CanViewDrop<const remove_reference_t<Rng>&> == (!is_view || copy_constructible<V>) );
if constexpr (is_view && copy_constructible<V>) {
constexpr bool is_noexcept = (is_nothrow_copy_constructible_v<V> && !is_subrange<V>);
STATIC_ASSERT(same_as<decltype(views::drop(as_const(rng), 4)), M>);
STATIC_ASSERT(noexcept(views::drop(as_const(rng), 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(as_const(rng), 4)), M>);
static_assert(noexcept(views::drop(as_const(rng), 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | closure), M>);
STATIC_ASSERT(noexcept(as_const(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | closure), M>);
static_assert(noexcept(as_const(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
STATIC_ASSERT(noexcept(as_const(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
static_assert(noexcept(as_const(rng) | pipeline) == is_noexcept);
} else if constexpr (!is_view) {
using RC = mapped_t<const remove_reference_t<Rng>&>;
constexpr bool is_noexcept = is_nothrow_constructible_v<RC, const remove_reference_t<Rng>&, int>;
STATIC_ASSERT(same_as<decltype(views::drop(as_const(rng), 4)), RC>);
STATIC_ASSERT(noexcept(views::drop(as_const(rng), 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(as_const(rng), 4)), RC>);
static_assert(noexcept(views::drop(as_const(rng), 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | closure), RC>);
STATIC_ASSERT(noexcept(as_const(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | closure), RC>);
static_assert(noexcept(as_const(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
STATIC_ASSERT(noexcept(as_const(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
static_assert(noexcept(as_const(rng) | pipeline) == is_noexcept);
}
// ... with rvalue argument
STATIC_ASSERT(CanViewDrop<remove_reference_t<Rng>> == (is_view || movable<remove_reference_t<Rng>>) );
static_assert(CanViewDrop<remove_reference_t<Rng>> == (is_view || movable<remove_reference_t<Rng>>) );
if constexpr (is_view) {
constexpr bool is_noexcept = is_nothrow_move_constructible_v<V> && !is_subrange<V>;
STATIC_ASSERT(same_as<decltype(views::drop(move(rng), 4)), M>);
STATIC_ASSERT(noexcept(views::drop(move(rng), 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(move(rng), 4)), M>);
static_assert(noexcept(views::drop(move(rng), 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | closure), M>);
STATIC_ASSERT(noexcept(move(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(move(rng) | closure), M>);
static_assert(noexcept(move(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
STATIC_ASSERT(noexcept(move(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
static_assert(noexcept(move(rng) | pipeline) == is_noexcept);
} else if constexpr (movable<remove_reference_t<Rng>>) {
using S = ranges::owning_view<remove_reference_t<Rng>>;
using RS = drop_view<S>;
constexpr bool is_noexcept = is_nothrow_move_constructible_v<remove_reference_t<Rng>>;
STATIC_ASSERT(same_as<decltype(views::drop(move(rng), 4)), RS>);
STATIC_ASSERT(noexcept(views::drop(move(rng), 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(move(rng), 4)), RS>);
static_assert(noexcept(views::drop(move(rng), 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | closure), RS>);
STATIC_ASSERT(noexcept(move(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(move(rng) | closure), RS>);
static_assert(noexcept(move(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | pipeline), mapped_t<mapped_t<mapped_t<RS>>>>);
STATIC_ASSERT(noexcept(move(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(rng) | pipeline), mapped_t<mapped_t<mapped_t<RS>>>>);
static_assert(noexcept(move(rng) | pipeline) == is_noexcept);
}
// ... with const rvalue argument
STATIC_ASSERT(CanViewDrop<const remove_reference_t<Rng>> == (is_view && copy_constructible<V>) );
static_assert(CanViewDrop<const remove_reference_t<Rng>> == (is_view && copy_constructible<V>) );
if constexpr (is_view && copy_constructible<V>) {
constexpr bool is_noexcept = is_nothrow_copy_constructible_v<V> && !is_subrange<V>;
STATIC_ASSERT(same_as<decltype(views::drop(move(as_const(rng)), 4)), M>);
STATIC_ASSERT(noexcept(views::drop(move(as_const(rng)), 4)) == is_noexcept);
static_assert(same_as<decltype(views::drop(move(as_const(rng)), 4)), M>);
static_assert(noexcept(views::drop(move(as_const(rng)), 4)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(as_const(rng)) | closure), M>);
STATIC_ASSERT(noexcept(move(as_const(rng)) | closure) == is_noexcept);
static_assert(same_as<decltype(move(as_const(rng)) | closure), M>);
static_assert(noexcept(move(as_const(rng)) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(as_const(rng)) | pipeline), pipeline_t<const remove_reference_t<Rng>>>);
STATIC_ASSERT(noexcept(move(as_const(rng)) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(as_const(rng)) | pipeline), pipeline_t<const remove_reference_t<Rng>>>);
static_assert(noexcept(move(as_const(rng)) | pipeline) == is_noexcept);
}
const bool is_empty = ranges::empty(expected);
@ -195,43 +195,43 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
// Validate deduction guide
same_as<drop_view<V>> auto r = drop_view{forward<Rng>(rng), 4};
using R = decltype(r);
STATIC_ASSERT(ranges::view<R>);
STATIC_ASSERT(input_range<R> == input_range<Rng>);
STATIC_ASSERT(forward_range<R> == forward_range<Rng>);
STATIC_ASSERT(bidirectional_range<R> == bidirectional_range<Rng>);
STATIC_ASSERT(random_access_range<R> == random_access_range<Rng>);
STATIC_ASSERT(contiguous_range<R> == contiguous_range<Rng>);
STATIC_ASSERT(borrowed_range<R> == borrowed_range<V>);
static_assert(ranges::view<R>);
static_assert(input_range<R> == input_range<Rng>);
static_assert(forward_range<R> == forward_range<Rng>);
static_assert(bidirectional_range<R> == bidirectional_range<Rng>);
static_assert(random_access_range<R> == random_access_range<Rng>);
static_assert(contiguous_range<R> == contiguous_range<Rng>);
static_assert(borrowed_range<R> == borrowed_range<V>);
// Validate drop_view::size
STATIC_ASSERT(CanMemberSize<R> == CanSize<Rng>);
static_assert(CanMemberSize<R> == CanSize<Rng>);
if constexpr (CanMemberSize<R>) {
assert(r.size() == static_cast<decltype(r.size())>(ranges::size(expected)));
} else {
STATIC_ASSERT(!CanSize<R>);
static_assert(!CanSize<R>);
}
// Validate view_interface::empty and operator bool
STATIC_ASSERT(CanMemberEmpty<R> == (sized_range<Rng> || forward_range<Rng>) );
STATIC_ASSERT(CanBool<R> == CanEmpty<R>);
static_assert(CanMemberEmpty<R> == (sized_range<Rng> || forward_range<Rng>) );
static_assert(CanBool<R> == CanEmpty<R>);
if constexpr (CanMemberEmpty<R>) {
assert(r.empty() == is_empty);
assert(static_cast<bool>(r) == !is_empty);
} else {
STATIC_ASSERT(CanEmpty<R> == CanSize<R>);
static_assert(CanEmpty<R> == CanSize<R>);
if constexpr (CanEmpty<R>) {
assert(ranges::empty(r) == is_empty);
assert(static_cast<bool>(r) == !is_empty);
}
}
STATIC_ASSERT(CanMemberEmpty<const R> == (random_access_range<const Rng> && sized_range<const Rng>) );
STATIC_ASSERT(CanBool<const R> == CanEmpty<const R>);
static_assert(CanMemberEmpty<const R> == (random_access_range<const Rng> && sized_range<const Rng>) );
static_assert(CanBool<const R> == CanEmpty<const R>);
if constexpr (CanMemberEmpty<const R>) {
assert(as_const(r).empty() == is_empty);
assert(static_cast<bool>(as_const(r)) == !is_empty);
} else {
STATIC_ASSERT(CanEmpty<const R> == CanSize<const R>);
static_assert(CanEmpty<const R> == CanSize<const R>);
if constexpr (CanEmpty<const R>) {
assert(ranges::empty(as_const(r)) == is_empty);
assert(static_cast<bool>(as_const(r)) == !is_empty);
@ -242,9 +242,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
assert(ranges::equal(r, expected));
// Validate drop_view::begin
STATIC_ASSERT(CanMemberBegin<R>);
STATIC_ASSERT(same_as<iterator_t<R>, iterator_t<V>>);
STATIC_ASSERT(CanBegin<const R&> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanMemberBegin<R>);
static_assert(same_as<iterator_t<R>, iterator_t<V>>);
static_assert(CanBegin<const R&> == (random_access_range<const V> && sized_range<const V>) );
if (forward_range<V>) { // intentionally not if constexpr
const same_as<iterator_t<R>> auto i = r.begin();
if (!is_empty) {
@ -260,7 +260,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
if constexpr (random_access_range<const V> && sized_range<const V>) {
STATIC_ASSERT(same_as<iterator_t<const R>, iterator_t<const V>>);
static_assert(same_as<iterator_t<const R>, iterator_t<const V>>);
const same_as<iterator_t<const R>> auto i3 = as_const(r).begin();
if (!is_empty) {
assert(*i3 == *i);
@ -269,9 +269,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
// Validate drop_view::end
STATIC_ASSERT(CanMemberEnd<R>);
STATIC_ASSERT(same_as<sentinel_t<R>, sentinel_t<V>>);
STATIC_ASSERT(CanEnd<const R&> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanMemberEnd<R>);
static_assert(same_as<sentinel_t<R>, sentinel_t<V>>);
static_assert(CanEnd<const R&> == (random_access_range<const V> && sized_range<const V>) );
if (!is_empty) {
same_as<sentinel_t<R>> auto i = r.end();
if constexpr (bidirectional_range<R> && common_range<R>) {
@ -290,9 +290,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
using ranges::const_iterator_t, ranges::const_sentinel_t, ranges::cbegin, ranges::cend;
// Validate view_interface::cbegin
STATIC_ASSERT(CanMemberCBegin<R> == input_range<V>);
STATIC_ASSERT(same_as<const_iterator_t<R>, const_iterator_t<V>>);
STATIC_ASSERT(CanMemberCBegin<const R&> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanMemberCBegin<R> == input_range<V>);
static_assert(same_as<const_iterator_t<R>, const_iterator_t<V>>);
static_assert(CanMemberCBegin<const R&> == (random_access_range<const V> && sized_range<const V>) );
if (forward_range<V>) { // intentionally not if constexpr
const same_as<const_iterator_t<R>> auto i = r.cbegin();
if (!is_empty) {
@ -308,7 +308,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
if constexpr (random_access_range<const V> && sized_range<const V>) {
STATIC_ASSERT(same_as<const_iterator_t<const R>, const_iterator_t<const V>>);
static_assert(same_as<const_iterator_t<const R>, const_iterator_t<const V>>);
const same_as<const_iterator_t<const R>> auto i3 = as_const(r).cbegin();
if (!is_empty) {
assert(*i3 == *i);
@ -317,9 +317,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
// Validate view_interface::cend
STATIC_ASSERT(CanMemberCEnd<R> == input_range<V>);
STATIC_ASSERT(same_as<const_sentinel_t<R>, const_sentinel_t<V>>);
STATIC_ASSERT(CanMemberCEnd<const R&> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanMemberCEnd<R> == input_range<V>);
static_assert(same_as<const_sentinel_t<R>, const_sentinel_t<V>>);
static_assert(CanMemberCEnd<const R&> == (random_access_range<const V> && sized_range<const V>) );
if (!is_empty) {
same_as<const_sentinel_t<R>> auto i = r.cend();
if constexpr (bidirectional_range<R> && common_range<R>) {
@ -336,9 +336,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
#endif // _HAS_CXX23
// Validate view_interface::data
STATIC_ASSERT(CanMemberData<R> == contiguous_range<V>);
STATIC_ASSERT(CanData<R&> == contiguous_range<V>);
STATIC_ASSERT(CanData<const R&> == (contiguous_range<const V> && sized_range<const V>) );
static_assert(CanMemberData<R> == contiguous_range<V>);
static_assert(CanData<R&> == contiguous_range<V>);
static_assert(CanData<const R&> == (contiguous_range<const V> && sized_range<const V>) );
if constexpr (contiguous_range<V>) {
const same_as<remove_reference_t<ranges::range_reference_t<V>>*> auto ptr1 = r.data();
assert(to_address(ptr1) == to_address(r.begin()));
@ -351,22 +351,22 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
// Validate view_interface::front and back
if (!is_empty) {
STATIC_ASSERT(CanMemberFront<R> == forward_range<V>);
static_assert(CanMemberFront<R> == forward_range<V>);
if constexpr (forward_range<V>) {
assert(r.front() == *begin(expected));
}
STATIC_ASSERT(CanMemberFront<const R> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanMemberFront<const R> == (random_access_range<const V> && sized_range<const V>) );
if constexpr (CanMemberFront<const R>) {
assert(as_const(r).front() == *begin(expected));
}
STATIC_ASSERT(CanMemberBack<R> == (bidirectional_range<R> && common_range<R>) );
static_assert(CanMemberBack<R> == (bidirectional_range<R> && common_range<R>) );
if constexpr (CanMemberBack<R>) {
assert(r.back() == *prev(end(expected)));
}
STATIC_ASSERT(
static_assert(
CanMemberBack<const R> == (common_range<const V> && random_access_range<const V> && sized_range<const V>) );
if constexpr (CanMemberBack<const R>) {
assert(as_const(r).back() == *prev(end(expected)));
@ -374,8 +374,8 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
// Validate view_interface::operator[]
STATIC_ASSERT(CanIndex<R> == random_access_range<V>);
STATIC_ASSERT(CanIndex<const R> == (random_access_range<const V> && sized_range<const V>) );
static_assert(CanIndex<R> == random_access_range<V>);
static_assert(CanIndex<const R> == (random_access_range<const V> && sized_range<const V>) );
if (!is_empty) {
if constexpr (CanIndex<R>) {
assert(r[0] == *r.begin());
@ -387,10 +387,10 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
// Validate drop_view::base() const&
STATIC_ASSERT(CanMemberBase<const R&> == copy_constructible<V>);
static_assert(CanMemberBase<const R&> == copy_constructible<V>);
if constexpr (CanMemberBase<const R&> && forward_range<V>) {
same_as<V> auto b1 = as_const(r).base();
STATIC_ASSERT(noexcept(as_const(r).base()) == is_nothrow_copy_constructible_v<V>);
static_assert(noexcept(as_const(r).base()) == is_nothrow_copy_constructible_v<V>);
if (!is_empty) {
assert(*b1.begin() == 0); // NB: depends on the test data
if constexpr (bidirectional_range<V> && common_range<V>) {
@ -402,7 +402,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
// Validate drop_view::base() && (NB: do this last since it leaves r moved-from)
if (forward_range<V>) { // intentionally not if constexpr
same_as<V> auto b2 = move(r).base();
STATIC_ASSERT(noexcept(move(r).base()) == is_nothrow_move_constructible_v<V>);
static_assert(noexcept(move(r).base()) == is_nothrow_move_constructible_v<V>);
if (!is_empty) {
assert(*b2.begin() == 0); // NB: depends on the test data
if constexpr (bidirectional_range<V> && common_range<V>) {
@ -502,7 +502,7 @@ constexpr void output_range_test() {
using R = test::range<output_iterator_tag, int, test::Sized::no, test::CanDifference::no, test::Common::no,
test::CanCompare::no, test::ProxyRef::yes, test::CanView::yes, test::Copyability::move_only>;
int some_writable_ints[] = {0, 1, 2, 3};
STATIC_ASSERT(same_as<decltype(views::drop(R{some_writable_ints}, 2)), ranges::drop_view<R>>);
static_assert(same_as<decltype(views::drop(R{some_writable_ints}, 2)), ranges::drop_view<R>>);
ranges::fill(R{some_writable_ints} | views::drop(2), 42);
assert(ranges::equal(some_writable_ints, initializer_list<int>{0, 1, 42, 42}));
}
@ -512,32 +512,32 @@ int main() {
{ // ... copyable
// Test all of the "reconstructible range" types: span, empty_view, subrange, basic_string_view, iota_view
constexpr span s0{some_ints};
STATIC_ASSERT(test_one(s0, only_four_ints));
static_assert(test_one(s0, only_four_ints));
test_one(s0, only_four_ints);
constexpr span<const int> s1{some_ints};
STATIC_ASSERT(test_one(s1, only_four_ints));
static_assert(test_one(s1, only_four_ints));
test_one(s1, only_four_ints);
STATIC_ASSERT(test_one(ranges::subrange{some_ints}, only_four_ints));
static_assert(test_one(ranges::subrange{some_ints}, only_four_ints));
test_one(ranges::subrange{some_ints}, only_four_ints);
STATIC_ASSERT(test_one(views::empty<int>, span<const int, 0>{}));
static_assert(test_one(views::empty<int>, span<const int, 0>{}));
test_one(views::empty<int>, span<const int, 0>{});
STATIC_ASSERT(test_one(basic_string_view{ranges::begin(some_ints), ranges::end(some_ints)}, only_four_ints));
static_assert(test_one(basic_string_view{ranges::begin(some_ints), ranges::end(some_ints)}, only_four_ints));
test_one(basic_string_view{ranges::begin(some_ints), ranges::end(some_ints)}, only_four_ints);
STATIC_ASSERT(test_one(ranges::iota_view{0, 8}, only_four_ints));
static_assert(test_one(ranges::iota_view{0, 8}, only_four_ints));
test_one(ranges::iota_view{0, 8}, only_four_ints);
}
// ... move-only
STATIC_ASSERT((move_only_test(), true));
static_assert((move_only_test(), true));
move_only_test();
// Validate non-views
{
STATIC_ASSERT(test_one(some_ints, only_four_ints));
static_assert(test_one(some_ints, only_four_ints));
test_one(some_ints, only_four_ints);
}
{
@ -550,17 +550,17 @@ int main() {
}
// Validate an output range
STATIC_ASSERT((output_range_test(), true));
static_assert((output_range_test(), true));
output_range_test();
STATIC_ASSERT((instantiation_test(), true));
static_assert((instantiation_test(), true));
instantiation_test();
{
// Validate a view borrowed range
constexpr auto v =
views::iota(0ull, ranges::size(some_ints)) | views::transform([](auto i) { return some_ints[i]; });
STATIC_ASSERT(test_one(v, only_four_ints));
static_assert(test_one(v, only_four_ints));
test_one(v, only_four_ints);
}

Просмотреть файл

@ -18,7 +18,7 @@ template <int X>
constexpr auto is_less_than = [](const auto& x) { return x < X; };
using Pred = remove_const_t<decltype(is_less_than<3>)>;
STATIC_ASSERT(is_nothrow_copy_constructible_v<Pred>&& is_nothrow_move_constructible_v<Pred>);
static_assert(is_nothrow_copy_constructible_v<Pred> && is_nothrow_move_constructible_v<Pred>);
constexpr auto pipeline = views::drop_while(is_less_than<3>) | views::drop_while(is_less_than<3>)
| views::drop_while(is_less_than<3>) | views::drop_while(is_less_than<3>);
@ -40,99 +40,99 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
using V = views::all_t<Rng>;
using R = drop_while_view<V, Pred>;
STATIC_ASSERT(ranges::view<R>);
STATIC_ASSERT(ranges::input_range<R>);
STATIC_ASSERT(forward_range<R> == forward_range<Rng>);
STATIC_ASSERT(bidirectional_range<R> == bidirectional_range<Rng>);
STATIC_ASSERT(random_access_range<R> == random_access_range<Rng>);
STATIC_ASSERT(contiguous_range<R> == contiguous_range<Rng>);
STATIC_ASSERT(borrowed_range<R> == borrowed_range<V>);
static_assert(ranges::view<R>);
static_assert(ranges::input_range<R>);
static_assert(forward_range<R> == forward_range<Rng>);
static_assert(bidirectional_range<R> == bidirectional_range<Rng>);
static_assert(random_access_range<R> == random_access_range<Rng>);
static_assert(contiguous_range<R> == contiguous_range<Rng>);
static_assert(borrowed_range<R> == borrowed_range<V>);
// Validate range adaptor object and range adaptor closure
constexpr auto closure = views::drop_while(is_less_than<3>);
// ... with lvalue argument
STATIC_ASSERT(CanViewDropWhile<Rng&> == (!is_view || copy_constructible<V>) );
static_assert(CanViewDropWhile<Rng&> == (!is_view || copy_constructible<V>) );
if constexpr (CanViewDropWhile<Rng&>) { // Validate lvalue
constexpr bool is_noexcept = !is_view || is_nothrow_copy_constructible_v<V>;
STATIC_ASSERT(same_as<decltype(views::drop_while(rng, is_less_than<3>)), R>);
STATIC_ASSERT(noexcept(views::drop_while(rng, is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(rng, is_less_than<3>)), R>);
static_assert(noexcept(views::drop_while(rng, is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(rng | closure), R>);
STATIC_ASSERT(noexcept(rng | closure) == is_noexcept);
static_assert(same_as<decltype(rng | closure), R>);
static_assert(noexcept(rng | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(rng | pipeline), pipeline_t<Rng&>>);
STATIC_ASSERT(noexcept(rng | pipeline) == is_noexcept);
static_assert(same_as<decltype(rng | pipeline), pipeline_t<Rng&>>);
static_assert(noexcept(rng | pipeline) == is_noexcept);
}
// ... with const lvalue argument
STATIC_ASSERT(CanViewDropWhile<const remove_reference_t<Rng>&> == (!is_view || copy_constructible<V>) );
static_assert(CanViewDropWhile<const remove_reference_t<Rng>&> == (!is_view || copy_constructible<V>) );
if constexpr (is_view && copy_constructible<V>) {
constexpr bool is_noexcept = is_nothrow_copy_constructible_v<V>;
STATIC_ASSERT(same_as<decltype(views::drop_while(as_const(rng), is_less_than<3>)), R>);
STATIC_ASSERT(noexcept(views::drop_while(as_const(rng), is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(as_const(rng), is_less_than<3>)), R>);
static_assert(noexcept(views::drop_while(as_const(rng), is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | closure), R>);
STATIC_ASSERT(noexcept(as_const(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | closure), R>);
static_assert(noexcept(as_const(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
STATIC_ASSERT(noexcept(as_const(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
static_assert(noexcept(as_const(rng) | pipeline) == is_noexcept);
} else if constexpr (!is_view) {
using RC = drop_while_view<ranges::ref_view<const remove_reference_t<Rng>>, Pred>;
constexpr bool is_noexcept = true;
STATIC_ASSERT(same_as<decltype(views::drop_while(as_const(rng), is_less_than<3>)), RC>);
STATIC_ASSERT(noexcept(views::drop_while(as_const(rng), is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(as_const(rng), is_less_than<3>)), RC>);
static_assert(noexcept(views::drop_while(as_const(rng), is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | closure), RC>);
STATIC_ASSERT(noexcept(as_const(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | closure), RC>);
static_assert(noexcept(as_const(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
STATIC_ASSERT(noexcept(as_const(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(as_const(rng) | pipeline), pipeline_t<const remove_reference_t<Rng>&>>);
static_assert(noexcept(as_const(rng) | pipeline) == is_noexcept);
}
// ... with rvalue argument
STATIC_ASSERT(CanViewDropWhile<remove_reference_t<Rng>> == (is_view || movable<remove_reference_t<Rng>>) );
static_assert(CanViewDropWhile<remove_reference_t<Rng>> == (is_view || movable<remove_reference_t<Rng>>) );
if constexpr (is_view) {
constexpr bool is_noexcept = is_nothrow_move_constructible_v<V>;
STATIC_ASSERT(same_as<decltype(views::drop_while(move(rng), is_less_than<3>)), R>);
STATIC_ASSERT(noexcept(views::drop_while(move(rng), is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(move(rng), is_less_than<3>)), R>);
static_assert(noexcept(views::drop_while(move(rng), is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | closure), R>);
STATIC_ASSERT(noexcept(move(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(move(rng) | closure), R>);
static_assert(noexcept(move(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
STATIC_ASSERT(noexcept(move(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
static_assert(noexcept(move(rng) | pipeline) == is_noexcept);
} else if constexpr (movable<remove_reference_t<Rng>>) {
using S = ranges::owning_view<remove_reference_t<Rng>>;
using RS = drop_while_view<S, Pred>;
constexpr bool is_noexcept = is_nothrow_move_constructible_v<remove_reference_t<Rng>>;
STATIC_ASSERT(same_as<decltype(views::drop_while(move(rng), is_less_than<3>)), RS>);
STATIC_ASSERT(noexcept(views::drop_while(move(rng), is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(move(rng), is_less_than<3>)), RS>);
static_assert(noexcept(views::drop_while(move(rng), is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | closure), RS>);
STATIC_ASSERT(noexcept(move(rng) | closure) == is_noexcept);
static_assert(same_as<decltype(move(rng) | closure), RS>);
static_assert(noexcept(move(rng) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
STATIC_ASSERT(noexcept(move(rng) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(rng) | pipeline), pipeline_t<remove_reference_t<Rng>>>);
static_assert(noexcept(move(rng) | pipeline) == is_noexcept);
}
// ... with const rvalue argument
STATIC_ASSERT(CanViewDropWhile<const remove_reference_t<Rng>> == (is_view && copy_constructible<V>) );
static_assert(CanViewDropWhile<const remove_reference_t<Rng>> == (is_view && copy_constructible<V>) );
if constexpr (is_view && copy_constructible<V>) {
constexpr bool is_noexcept = is_nothrow_copy_constructible_v<V>;
STATIC_ASSERT(same_as<decltype(views::drop_while(move(as_const(rng)), is_less_than<3>)), R>);
STATIC_ASSERT(noexcept(views::drop_while(move(as_const(rng)), is_less_than<3>)) == is_noexcept);
static_assert(same_as<decltype(views::drop_while(move(as_const(rng)), is_less_than<3>)), R>);
static_assert(noexcept(views::drop_while(move(as_const(rng)), is_less_than<3>)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(as_const(rng)) | closure), R>);
STATIC_ASSERT(noexcept(move(as_const(rng)) | closure) == is_noexcept);
static_assert(same_as<decltype(move(as_const(rng)) | closure), R>);
static_assert(noexcept(move(as_const(rng)) | closure) == is_noexcept);
STATIC_ASSERT(same_as<decltype(move(as_const(rng)) | pipeline), pipeline_t<const remove_reference_t<Rng>>>);
STATIC_ASSERT(noexcept(move(as_const(rng)) | pipeline) == is_noexcept);
static_assert(same_as<decltype(move(as_const(rng)) | pipeline), pipeline_t<const remove_reference_t<Rng>>>);
static_assert(noexcept(move(as_const(rng)) | pipeline) == is_noexcept);
}
// Validate deduction guide
@ -147,30 +147,30 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
{ // Validate drop_while_view::pred
[[maybe_unused]] same_as<Pred> auto pred_copy = as_const(r).pred();
STATIC_ASSERT(noexcept(as_const(r).pred()));
static_assert(noexcept(as_const(r).pred()));
}
const bool is_empty = ranges::empty(expected);
// Validate view_interface::empty and operator bool
STATIC_ASSERT(CanMemberEmpty<R> == forward_range<Rng>);
STATIC_ASSERT(CanBool<R> == CanEmpty<R>);
static_assert(CanMemberEmpty<R> == forward_range<Rng>);
static_assert(CanBool<R> == CanEmpty<R>);
if constexpr (CanMemberEmpty<R>) {
assert(r.empty() == is_empty);
assert(static_cast<bool>(r) == !is_empty);
} else {
STATIC_ASSERT(CanEmpty<R> == CanSize<R>);
static_assert(CanEmpty<R> == CanSize<R>);
if constexpr (CanEmpty<R>) {
assert(ranges::empty(r) == is_empty);
assert(static_cast<bool>(r) == !is_empty);
}
}
STATIC_ASSERT(!CanEmpty<const R>);
STATIC_ASSERT(!CanBool<const R>);
static_assert(!CanEmpty<const R>);
static_assert(!CanBool<const R>);
// Validate drop_while_view::begin
STATIC_ASSERT(CanMemberBegin<R>);
static_assert(CanMemberBegin<R>);
if (forward_range<V>) { // intentionally not if constexpr
// Ditto "let's make some extra calls because memoization"
const same_as<iterator_t<R>> auto i = r.begin();
@ -190,11 +190,11 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
}
STATIC_ASSERT(!CanBegin<const R>);
static_assert(!CanBegin<const R>);
}
// Validate drop_while_view::end
STATIC_ASSERT(CanMemberEnd<R>);
static_assert(CanMemberEnd<R>);
if (!is_empty) {
if constexpr (common_range<V>) {
same_as<iterator_t<R>> auto i = r.end();
@ -210,14 +210,14 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
assert(*prev(r2.end()) == *prev(end(expected)));
}
STATIC_ASSERT(!CanEnd<const R>);
static_assert(!CanEnd<const R>);
}
#if _HAS_CXX23
using ranges::const_iterator_t, ranges::const_sentinel_t, ranges::cbegin, ranges::cend;
// Validate view_interface::cbegin
STATIC_ASSERT(CanMemberCBegin<R> == ranges::input_range<V>);
static_assert(CanMemberCBegin<R> == ranges::input_range<V>);
if (forward_range<V>) { // intentionally not if constexpr
const same_as<const_iterator_t<R>> auto i = r.cbegin();
if (!is_empty) {
@ -234,11 +234,11 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}
}
STATIC_ASSERT(!CanCBegin<const R>);
static_assert(!CanCBegin<const R>);
}
// Validate view_interface::cend
STATIC_ASSERT(CanMemberCEnd<R> == ranges::input_range<V>);
static_assert(CanMemberCEnd<R> == ranges::input_range<V>);
if (!is_empty) {
if constexpr (common_range<V>) {
same_as<const_iterator_t<R>> auto i = r.cend();
@ -254,58 +254,58 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
assert(*prev(r2.cend()) == *prev(cend(expected)));
}
STATIC_ASSERT(!CanCEnd<const R>);
static_assert(!CanCEnd<const R>);
}
#endif // _HAS_CXX23
// Validate view_interface::data
STATIC_ASSERT(CanMemberData<R> == contiguous_range<V>);
STATIC_ASSERT(CanData<R&> == contiguous_range<V>);
static_assert(CanMemberData<R> == contiguous_range<V>);
static_assert(CanData<R&> == contiguous_range<V>);
if constexpr (contiguous_range<V>) {
const same_as<remove_reference_t<ranges::range_reference_t<V>>*> auto ptr1 = r.data();
assert(ptr1 == to_address(r.begin()));
}
STATIC_ASSERT(!CanData<const R&>);
static_assert(!CanData<const R&>);
// Validate view_interface::size
STATIC_ASSERT(CanMemberSize<R> == CanSize<Rng>);
static_assert(CanMemberSize<R> == CanSize<Rng>);
if constexpr (CanMemberSize<R>) {
assert(r.size() == static_cast<decltype(r.size())>(ranges::size(expected)));
} else {
STATIC_ASSERT(!CanSize<R>);
static_assert(!CanSize<R>);
}
// Validate view_interface::operator[]
STATIC_ASSERT(CanIndex<R> == random_access_range<V>);
static_assert(CanIndex<R> == random_access_range<V>);
if constexpr (CanIndex<R>) {
if (!is_empty) {
assert(r[0] == expected[0]);
}
}
STATIC_ASSERT(!CanIndex<const R>);
static_assert(!CanIndex<const R>);
// Validate view_interface::front and back
STATIC_ASSERT(CanMemberFront<R> == forward_range<V>);
static_assert(CanMemberFront<R> == forward_range<V>);
if constexpr (CanMemberFront<R>) {
if (!is_empty) {
assert(r.front() == *begin(expected));
}
}
STATIC_ASSERT(!CanMemberFront<const R>);
static_assert(!CanMemberFront<const R>);
STATIC_ASSERT(CanMemberBack<R> == (bidirectional_range<R> && common_range<R>) );
static_assert(CanMemberBack<R> == (bidirectional_range<R> && common_range<R>) );
if constexpr (CanMemberBack<R>) {
if (!is_empty) {
assert(r.back() == *prev(end(expected)));
}
}
STATIC_ASSERT(!CanMemberBack<const R>);
static_assert(!CanMemberBack<const R>);
// Validate drop_while_view::base() const&
STATIC_ASSERT(CanMemberBase<const R&> == copy_constructible<V>);
static_assert(CanMemberBase<const R&> == copy_constructible<V>);
if constexpr (copy_constructible<V> && forward_range<V>) {
same_as<V> auto b1 = as_const(r).base();
STATIC_ASSERT(noexcept(as_const(r).base()) == is_nothrow_copy_constructible_v<V>);
static_assert(noexcept(as_const(r).base()) == is_nothrow_copy_constructible_v<V>);
if (!is_empty) {
assert(*b1.begin() == 0); // NB: depends on the test data
if constexpr (bidirectional_range<V> && common_range<V>) {
@ -316,7 +316,7 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
if (forward_range<V>) { // intentionally not if constexpr
same_as<V> auto b2 = move(r).base();
STATIC_ASSERT(noexcept(move(r).base()) == is_nothrow_move_constructible_v<V>);
static_assert(noexcept(move(r).base()) == is_nothrow_move_constructible_v<V>);
if (!is_empty) {
assert(*b2.begin() == 0); // NB: depends on the test data
if constexpr (bidirectional_range<V> && common_range<V>) {
@ -374,7 +374,7 @@ int main() {
// Validate views
{ // ... copyable
constexpr span<const int> s{some_ints};
STATIC_ASSERT(test_one(s, expected_output));
static_assert(test_one(s, expected_output));
test_one(s, expected_output);
}
{ // ... move-only
@ -389,7 +389,7 @@ int main() {
// Validate non-views
{
STATIC_ASSERT(test_one(some_ints, expected_output));
static_assert(test_one(some_ints, expected_output));
test_one(some_ints, expected_output);
}
{
@ -408,21 +408,21 @@ int main() {
auto r0 = some_ints | dwr_pipe;
using R0 = decltype(r0);
STATIC_ASSERT(ranges::bidirectional_range<R0> && ranges::view<R0>);
static_assert(ranges::bidirectional_range<R0> && ranges::view<R0>);
assert(ranges::equal(r0, views::reverse(expected_output)));
auto r1 = some_ints | rdw_pipe;
using R1 = decltype(r1);
STATIC_ASSERT(ranges::bidirectional_range<R1> && ranges::view<R1>);
static_assert(ranges::bidirectional_range<R1> && ranges::view<R1>);
assert(ranges::equal(r1, views::reverse(expected_output_reverse)));
}
{ // empty range
STATIC_ASSERT(test_one(span<const int, 0>{}, span<const int, 0>{}));
static_assert(test_one(span<const int, 0>{}, span<const int, 0>{}));
test_one(span<const int, 0>{}, span<const int, 0>{});
}
STATIC_ASSERT((instantiation_test(), true));
static_assert((instantiation_test(), true));
instantiation_test();
{ // Validate **non-standard guarantee** that predicates are moved into the range adaptor closure, and into the view

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше