[MLIR][NVVM] Add tcgen05 alloc/dealloc Ops (#125674)
[llvm-project.git] / libcxx / test / std / thread / thread.threads / thread.thread.class / thread.thread.id / parse.pass.cpp
blobf0db4e18a0235e5209fd45e56741300c67a4b89e
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: no-threads
12 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
14 // <thread>
16 // template<class charT>
17 // struct formatter<thread::id, charT>;
19 // template<class ParseContext>
20 // constexpr typename ParseContext::iterator
21 // parse(ParseContext& ctx);
23 // Note this tests the basics of this function. It's tested in more detail in
24 // the format functions test.
26 #include <cassert>
27 #include <concepts>
28 #include <format>
29 #include <memory>
30 #include <thread>
32 #include "test_macros.h"
33 #include "make_string.h"
35 #define SV(S) MAKE_STRING_VIEW(CharT, S)
37 template <class StringViewT>
38 constexpr void test_parse(StringViewT fmt, std::size_t offset) {
39 using CharT = typename StringViewT::value_type;
40 auto parse_ctx = std::basic_format_parse_context<CharT>(fmt);
41 std::formatter<std::thread::id, CharT> formatter;
42 static_assert(std::semiregular<decltype(formatter)>);
44 std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
45 // std::to_address works around LWG3989 and MSVC STL's iterator debugging mechanism.
46 assert(std::to_address(it) == std::to_address(fmt.end()) - offset);
49 template <class CharT>
50 constexpr void test_fmt() {
51 test_parse(SV(""), 0);
52 test_parse(SV("1"), 0);
54 test_parse(SV("}"), 1);
55 test_parse(SV("1}"), 1);
58 constexpr bool test() {
59 test_fmt<char>();
60 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
61 test_fmt<wchar_t>();
62 #endif
64 return true;
67 int main(int, char**) {
68 test();
69 static_assert(test());
71 return 0;