}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range>(std::allocator<char>());
- do_test<Range>(__gnu_test::uneq_allocator<char>(42));
do_test<Range>(std::allocator<wchar_t>());
- do_test<Range>(__gnu_test::uneq_allocator<wchar_t>(42));
+
+ if not consteval {
+ do_test<Range>(__gnu_test::uneq_allocator<char>(42));
+ do_test<Range>(__gnu_test::uneq_allocator<wchar_t>(42));
+ }
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to char
struct C {
- C(char v) : val(v) { }
- operator char() && { return val; }
- bool operator==(char b) const { return b == val; }
+ constexpr C(char v) : val(v) { }
+ constexpr operator char() && { return val; }
+ constexpr bool operator==(char b) const { return b == val; }
char val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
-#if _GLIBCXX_USE_CXX11_ABI
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::string_view>(std::allocator<char>());
-#endif // _GLIBCXX_USE_CXX11_ABI
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+#if _GLIBCXX_USE_CXX11_ABI
+ static_assert( test_ranges() );
+#endif // _GLIBCXX_USE_CXX11_ABI
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<char>>();
do_test<Range, __gnu_test::SimpleAllocator<wchar_t>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to char
struct C {
- C(char v) : val(v) { }
- operator char() && { return val; }
- bool operator==(char b) const { return b == val; }
+ constexpr C(char v) : val(v) { }
+ constexpr operator char() && { return val; }
+ constexpr bool operator==(char b) const { return b == val; }
char val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
VERIFY( c == "1234abcd1234" );
}
-constexpr bool
-test_constexpr()
-{
-#if _GLIBCXX_USE_CXX11_ABI
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::string_view, std::allocator<char>>();
-#endif // _GLIBCXX_USE_CXX11_ABI
- return true;
-}
-
int main()
{
test_ranges();
test_overlapping();
- static_assert( test_constexpr() );
+#if _GLIBCXX_USE_CXX11_ABI
+ static_assert( test_ranges() );
+#endif // _GLIBCXX_USE_CXX11_ABI
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<char>>();
do_test<Range, __gnu_test::SimpleAllocator<wchar_t>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to char
struct C {
- C(char v) : val(v) { }
- operator char() && { return val; }
- bool operator==(char b) const { return b == val; }
+ constexpr C(char v) : val(v) { }
+ constexpr operator char() && { return val; }
+ constexpr bool operator==(char b) const { return b == val; }
char val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
VERIFY( c == "1234" );
}
-constexpr bool
-test_constexpr()
-{
-#if _GLIBCXX_USE_CXX11_ABI
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::string_view, std::allocator<char>>();
-#endif // _GLIBCXX_USE_CXX11_ABI
- return true;
-}
-
int main()
{
test_ranges();
test_overlapping();
- static_assert( test_constexpr() );
+#if _GLIBCXX_USE_CXX11_ABI
+ static_assert( test_ranges() );
+#endif // _GLIBCXX_USE_CXX11_ABI
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<char>>();
do_test<Range, __gnu_test::SimpleAllocator<wchar_t>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to char
struct C {
- C(char v) : val(v) { }
- operator char() && { return val; }
- bool operator==(char b) const { return b == val; }
+ constexpr C(char v) : val(v) { }
+ constexpr operator char() && { return val; }
+ constexpr bool operator==(char b) const { return b == val; }
char val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
VERIFY( c == "12123434abcd" );
}
-constexpr bool
-test_constexpr()
-{
-#if _GLIBCXX_USE_CXX11_ABI
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::string_view, std::allocator<char>>();
-#endif // _GLIBCXX_USE_CXX11_ABI
- return true;
-}
-
int main()
{
test_ranges();
test_overlapping();
- static_assert( test_constexpr() );
+#if _GLIBCXX_USE_CXX11_ABI
+ static_assert( test_ranges() );
+#endif // _GLIBCXX_USE_CXX11_ABI
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<char>>();
do_test<Range, __gnu_test::SimpleAllocator<wchar_t>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to char
struct C {
- C(char v) : val(v) { }
- operator char() && { return val; }
- bool operator==(char b) const { return b == val; }
+ constexpr C(char v) : val(v) { }
+ constexpr operator char() && { return val; }
+ constexpr bool operator==(char b) const { return b == val; }
char val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
VERIFY( c == "12123434abcd" );
}
-constexpr bool
-test_constexpr()
-{
-#if _GLIBCXX_USE_CXX11_ABI
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::string_view, std::allocator<char>>();
-#endif // _GLIBCXX_USE_CXX11_ABI
- return true;
-}
-
int main()
{
test_ranges();
test_overlapping();
- static_assert( test_constexpr() );
+#if _GLIBCXX_USE_CXX11_ABI
+ static_assert( test_ranges() );
+#endif // _GLIBCXX_USE_CXX11_ABI
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range>(std::allocator<bool>());
- do_test<Range>(__gnu_test::uneq_allocator<bool>(42));
+ if not consteval {
+ do_test<Range>(__gnu_test::uneq_allocator<bool>(42));
+ }
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to bool
struct C {
- C(bool v) : val(v) { }
- operator bool() && { return val; }
- bool operator==(bool b) const { return b == val; }
+ constexpr C(bool v) : val(v) { }
+ constexpr operator bool() && { return val; }
+ constexpr bool operator==(bool b) const { return b == val; }
bool val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<bool>>(std::allocator<bool>());
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<bool>>();
do_test<Range, __gnu_test::SimpleAllocator<bool>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to bool
struct C {
- C(bool v) : val(v) { }
- operator bool() && { return val; }
- bool operator==(bool b) const { return b == val; }
+ constexpr C(bool v) : val(v) { }
+ constexpr operator bool() && { return val; }
+ constexpr bool operator==(bool b) const { return b == val; }
bool val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>, std::allocator<bool>>();
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<bool>>();
do_test<Range, __gnu_test::SimpleAllocator<bool>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to bool
struct C {
- C(bool v) : val(v) { }
- operator bool() && { return val; }
- bool operator==(bool b) const { return b == val; }
+ constexpr C(bool v) : val(v) { }
+ constexpr operator bool() && { return val; }
+ constexpr bool operator==(bool b) const { return b == val; }
bool val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
constexpr bool
test_constexpr()
{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>, std::allocator<bool>>();
+ test_ranges();
// Some basic tests for overlapping ranges in constant expressions.
using I = std::vector<bool>::iterator;
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<bool>>();
do_test<Range, __gnu_test::SimpleAllocator<bool>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to bool
struct C {
- C(bool v) : val(v) { }
- operator bool() && { return val; }
- bool operator==(bool b) const { return b == val; }
+ constexpr C(bool v) : val(v) { }
+ constexpr operator bool() && { return val; }
+ constexpr bool operator==(bool b) const { return b == val; }
bool val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<bool>, std::allocator<bool>>();
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range>(std::allocator<int>());
- do_test<Range>(__gnu_test::uneq_allocator<int>(42));
+ if not consteval {
+ do_test<Range>(__gnu_test::uneq_allocator<int>(42));
+ }
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to int
struct C {
- C(int v) : val(v) { }
- operator int() && { return val; }
- bool operator==(int b) const { return b == val; }
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+ constexpr bool operator==(int b) const { return b == val; }
int val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>>(std::allocator<int>());
- return true;
-}
-
void
test_pr120367()
{
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
test_pr120367();
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<int>>();
do_test<Range, __gnu_test::SimpleAllocator<int>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to int
struct C {
- C(int v) : val(v) { }
- operator int() && { return val; }
- bool operator==(int b) const { return b == val; }
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+ constexpr bool operator==(int b) const { return b == val; }
int val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-void
+constexpr void
test_overlapping()
{
using __gnu_test::test_input_range;
}
}
-constexpr bool
-test_constexpr()
+int main()
{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>, std::allocator<int>>();
-
- // Some basic tests for overlapping ranges in constant expressions.
- struct InputRange
- {
- struct Sent { const void* end; };
-
- struct Iter
- {
- using value_type = int;
- using difference_type = int;
- constexpr explicit Iter(int* p) : ptr(p) { }
- constexpr Iter& operator++() { ++ptr; return *this; }
- constexpr Iter operator++(int) { auto i = *this; ++ptr; return i; }
- constexpr int operator*() const { return *ptr; }
- constexpr bool operator==(const Iter&) const = default;
- constexpr bool operator==(const Sent& s) const { return ptr == s.end; }
- int* ptr;
- };
-
- Iter iter;
- Sent sent;
-
- constexpr InputRange(int* f, int* l) : iter{f}, sent{l} { }
- constexpr Iter begin() const { return iter; }
- constexpr Sent end() const { return sent; }
+ auto test_all = [] {
+ test_ranges();
+ test_overlapping();
+ return true;
};
- static_assert( std::ranges::input_range<InputRange> );
- static_assert( ! std::ranges::forward_range<InputRange> );
-
- std::vector<int> vec(5);
-
- // Test overlapping input ranges
- vec.resize(vec.capacity());
- vec.append_range(InputRange(vec.data(), vec.data() + 3)); // no capacity
- vec.reserve(vec.capacity() + 2);
- vec.append_range(InputRange(vec.data(), vec.data() + 4)); // some capacity
- vec.reserve(vec.capacity() + 6);
- vec.append_range(InputRange(vec.data(), vec.data() + 5)); // enough capacity
-
- // Test overlapping forward ranges
- vec.resize(vec.capacity());
- vec.append_range(std::span<int>(vec)); // no capacity
- vec.reserve(vec.size() + 2);
- vec.append_range(std::span<int>(vec).subspan(1, 4)); // some capacity
- vec.reserve(vec.size() + 6);
- vec.append_range(std::span<int>(vec).subspan(1, 5)); // enough capacity
- return true;
-}
-
-int main()
-{
- test_ranges();
- test_overlapping();
- static_assert( test_constexpr() );
+ test_all();
+ static_assert( test_all() );
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<int>>();
do_test<Range, __gnu_test::SimpleAllocator<int>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to int
struct C {
- C(int v) : val(v) { }
- operator int() && { return val; }
- bool operator==(int b) const { return b == val; }
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+ constexpr bool operator==(int b) const { return b == val; }
int val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>, std::allocator<int>>();
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
}
}
template<typename Range>
-void
+constexpr void
do_test_a()
{
do_test<Range, std::allocator<int>>();
do_test<Range, __gnu_test::SimpleAllocator<int>>();
}
-bool
+constexpr bool
test_ranges()
{
using namespace __gnu_test;
// Not lvalue-convertible to int
struct C {
- C(int v) : val(v) { }
- operator int() && { return val; }
- bool operator==(int b) const { return b == val; }
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+ constexpr bool operator==(int b) const { return b == val; }
int val;
};
using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
return true;
}
-constexpr bool
-test_constexpr()
-{
- // XXX: this doesn't test the non-forward_range code paths are constexpr.
- do_test<std::span<short>, std::allocator<int>>();
- return true;
-}
-
int main()
{
test_ranges();
- static_assert( test_constexpr() );
+ static_assert( test_ranges() );
}
constexpr SimpleAllocator() noexcept { }
template <class T>
+ constexpr
SimpleAllocator(const SimpleAllocator<T>&) { }
+ _GLIBCXX20_CONSTEXPR
Tp *allocate(std::size_t n)
{ return std::allocator<Tp>().allocate(n); }
+ _GLIBCXX20_CONSTEXPR
void deallocate(Tp *p, std::size_t n)
{ std::allocator<Tp>().deallocate(p, n); }
};
template <class T, class U>
+ constexpr
bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&)
{ return true; }
template <class T, class U>
+ constexpr
bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&)
{ return false; }