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
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12 // [container.adaptors.format]
13 // For each of queue, priority_queue, and stack, the library provides the
14 // following formatter specialization where adaptor-type is the name of the
17 // template<class charT, class T, formattable<charT> Container, class... U>
18 // struct formatter<adaptor-type<T, Container, U...>, charT>
20 // template<class ParseContext>
21 // constexpr typename ParseContext::iterator
22 // parse(ParseContext& ctx);
24 // Note this tests the basics of this function. It's tested in more detail in
25 // the format functions test.
33 #include "test_format_context.h"
34 #include "test_macros.h"
35 #include "make_string.h"
37 #define SV(S) MAKE_STRING_VIEW(CharT, S)
39 template <class Arg
, class StringViewT
>
40 constexpr void test_parse(StringViewT fmt
, std::size_t offset
) {
41 using CharT
= typename
StringViewT::value_type
;
42 auto parse_ctx
= std::basic_format_parse_context
<CharT
>(fmt
);
43 std::formatter
<Arg
, CharT
> formatter
;
44 static_assert(std::semiregular
<decltype(formatter
)>);
46 std::same_as
<typename
StringViewT::iterator
> auto it
= formatter
.parse(parse_ctx
);
47 assert(it
== fmt
.end() - offset
);
50 template <class StringViewT
>
51 constexpr void test_parse(StringViewT fmt
, std::size_t offset
) {
52 test_parse
<std::queue
<int>>(fmt
, offset
);
53 test_parse
<std::priority_queue
<int>>(fmt
, offset
);
54 test_parse
<std::stack
<int>>(fmt
, offset
);
57 template <class CharT
>
58 constexpr void test_fmt() {
59 test_parse(SV(""), 0);
60 test_parse(SV(":d"), 0);
62 test_parse(SV("}"), 1);
63 test_parse(SV(":d}"), 1);
66 constexpr bool test() {
68 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
75 int main(int, char**) {
77 static_assert(test());