[RISCV] Add MIPS P8700 processor (#119882)
[llvm-project.git] / libcxx / test / std / utilities / format / format.range / format.range.fmtdef / parse.pass.cpp
blob156f0ee964db0410d669bd3a03ab426dec1cf286
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
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // <format>
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);
22 #include <array>
23 #include <cassert>
24 #include <concepts>
25 #include <format>
26 #include <memory>
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() {
55 test_fmt<char>();
56 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
57 test_fmt<wchar_t>();
58 #endif
60 return true;
63 int main(int, char**) {
64 test();
65 static_assert(test());
67 return 0;