| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 |
| 10 | |
| 11 | // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME |
| 12 | |
| 13 | // <format> |
| 14 | |
| 15 | // template<class T, class charT = char> |
| 16 | // requires same_as<remove_cvref_t<T>, T> && formattable<T, charT> |
| 17 | // class range_formatter |
| 18 | |
| 19 | // constexpr formatter<T, charT>& underlying() noexcept; |
| 20 | // constexpr const formatter<T, charT>& underlying() const noexcept; |
| 21 | |
| 22 | #include <concepts> |
| 23 | #include <format> |
| 24 | |
| 25 | #include "test_macros.h" |
| 26 | |
| 27 | template <class CharT> |
| 28 | constexpr void test_underlying() { |
| 29 | { |
| 30 | std::range_formatter<int, CharT> formatter; |
| 31 | [[maybe_unused]] std::same_as<std::formatter<int, CharT>&> decltype(auto) underlying = formatter.underlying(); |
| 32 | static_assert(noexcept(formatter.underlying())); |
| 33 | } |
| 34 | { |
| 35 | const std::range_formatter<int, CharT> formatter; |
| 36 | [[maybe_unused]] std::same_as<const std::formatter<int, CharT>&> decltype(auto) underlying = formatter.underlying(); |
| 37 | static_assert(noexcept(formatter.underlying())); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | constexpr bool test() { |
| 42 | test_underlying<char>(); |
| 43 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 44 | test_underlying<wchar_t>(); |
| 45 | #endif |
| 46 | |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | int main(int, char**) { |
| 51 | test(); |
| 52 | static_assert(test()); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |