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
10 // UNSUPPORTED: no-threads
12 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
16 // template<class charT>
17 // struct formatter<thread::id, charT>;
19 // template<class FormatContext>
20 // typename FormatContext::iterator
21 // format(const T& r, FormatContext& ctx) const;
23 // Note this tests the basics of this function. It's tested in more detail in
24 // the format functions test.
31 #include "test_format_context.h"
32 #include "test_macros.h"
33 #include "make_string.h"
35 #define SV(S) MAKE_STRING_VIEW(CharT, S)
37 template <class StringViewT
>
38 void test_format(StringViewT expected
, std::thread::id arg
) {
39 using CharT
= typename
StringViewT::value_type
;
40 using String
= std::basic_string
<CharT
>;
41 using OutIt
= std::back_insert_iterator
<String
>;
42 using FormatCtxT
= std::basic_format_context
<OutIt
, CharT
>;
44 const std::formatter
<std::thread::id
, CharT
> formatter
;
47 OutIt out
= std::back_inserter(result
);
48 FormatCtxT format_ctx
= test_format_context_create
<OutIt
, CharT
>(out
, std::make_format_args
<FormatCtxT
>(arg
));
49 formatter
.format(arg
, format_ctx
);
50 assert(result
== expected
);
53 template <class CharT
>
55 #if !defined(__APPLE__) && !defined(__FreeBSD__)
56 test_format(SV("0"), std::thread::id());
58 test_format(SV("0x0"), std::thread::id());
64 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
69 int main(int, char**) {