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

source code of libcxx/test/std/utilities/format/format.range/format.range.formatter/underlying.pass.cpp