1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
15 // template<ranges::input_range R, class charT>
16 // struct range-default-formatter<range_format::sequence, R, charT>
18 // template<class ParseContext>
19 // constexpr typename ParseContext::iterator
20 // parse(ParseContext& ctx);
28 #include "test_macros.h"
29 #include "make_string.h"
31 #define SV(S) MAKE_STRING_VIEW(CharT, S)
33 template <class StringViewT
>
34 constexpr void test_parse(StringViewT fmt
, std::size_t offset
) {
35 using CharT
= typename
StringViewT::value_type
;
36 auto parse_ctx
= std::basic_format_parse_context
<CharT
>(fmt
);
37 std::formatter
<std::array
<int, 2>, CharT
> formatter
;
38 static_assert(std::semiregular
<decltype(formatter
)>);
40 std::same_as
<typename
StringViewT::iterator
> auto it
= formatter
.parse(parse_ctx
);
41 // std::to_address works around LWG3989 and MSVC STL's iterator debugging mechanism.
42 assert(std::to_address(it
) == std::to_address(fmt
.end()) - offset
);
45 template <class CharT
>
46 constexpr void test_fmt() {
47 test_parse(SV(""), 0);
48 test_parse(SV(":5"), 0);
50 test_parse(SV("}"), 1);
51 test_parse(SV(":5}"), 1);
54 constexpr bool test() {
56 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
63 int main(int, char**) {
65 static_assert(test());