//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // // template // constexpr auto operator<=>(basic_string_view lhs, basic_string_view rhs); // // LWG 3432 // [string.view]/4 // Mandates: R denotes a comparison category type ([cmp.categories]). #include #include "test_macros.h" template struct traits { typedef CharT char_type; typedef int int_type; typedef std::streamoff off_type; typedef std::streampos pos_type; typedef std::mbstate_t state_type; using comparison_category = Ordering; static constexpr void assign(char_type&, const char_type&) noexcept; static constexpr bool eq(char_type&, const char_type&) noexcept; static constexpr bool lt(char_type&, const char_type&) noexcept; static constexpr int compare(const char_type*, const char_type*, std::size_t) { return 0; } static constexpr std::size_t length(const char_type*); static constexpr const char_type* find(const char_type*, std::size_t, const char_type&); static constexpr char_type* move(char_type*, const char_type*, std::size_t); static constexpr char_type* copy(char_type*, const char_type*, std::size_t); static constexpr char_type* assign(char_type*, std::size_t, char_type); static constexpr int_type not_eof(int_type) noexcept; static constexpr char_type to_char_type(int_type) noexcept; static constexpr int_type to_int_type(char_type) noexcept; static constexpr bool eq_int_type(int_type, int_type) noexcept; static constexpr int_type eof() noexcept; }; template void test() { using type = std::basic_string_view>; if constexpr (Valid) type{} <=> type{}; else #ifndef TEST_HAS_NO_WIDE_CHARACTERS // These diagnostics are issued for // - Every invalid ordering // - Every type // expected-error-re@string_view:* 15 {{static assertion failed{{.*}}return type is not a comparison category type}} // This diagnostic is not issued for Ordering == void. // expected-error@string_view:* 10 {{no matching conversion for static_cast from}} #else // One less test run when wchar_t is unavailable. // expected-error-re@string_view:* 12 {{static assertion failed{{.*}}return type is not a comparison category type}} // expected-error@string_view:* 8 {{no matching conversion for static_cast from}} #endif type{} <=> type{}; } template void test_all_orders() { test(); test(); test(); test(); test(); test(); } void test_all_types() { test_all_orders(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test_all_orders(); #endif test_all_orders(); test_all_orders(); test_all_orders(); }