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 |
5 | // |
6 | //===----------------------------------------------------------------------===// |
7 | |
8 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
9 | |
10 | // <format> |
11 | |
12 | // constexpr begin() const noexcept; |
13 | |
14 | #include <format> |
15 | |
16 | #include <cassert> |
17 | #include <string_view> |
18 | |
19 | #include "test_macros.h" |
20 | |
21 | template <class CharT> |
22 | constexpr void test(const CharT* fmt) { |
23 | { |
24 | std::basic_format_parse_context<CharT> context(fmt); |
25 | assert(std::to_address(context.begin()) == &fmt[0]); |
26 | ASSERT_NOEXCEPT(context.begin()); |
27 | } |
28 | { |
29 | std::basic_string_view view{fmt}; |
30 | std::basic_format_parse_context context(view); |
31 | assert(context.begin() == view.begin()); |
32 | ASSERT_NOEXCEPT(context.begin()); |
33 | } |
34 | } |
35 | |
36 | constexpr bool test() { |
37 | test(fmt: "abc" ); |
38 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
39 | test(fmt: L"abc" ); |
40 | #endif |
41 | #ifndef TEST_HAS_NO_CHAR8_T |
42 | test(fmt: u8"abc" ); |
43 | #endif |
44 | test(fmt: u"abc" ); |
45 | test(fmt: U"abc" ); |
46 | |
47 | return true; |
48 | } |
49 | |
50 | int main(int, char**) { |
51 | test(); |
52 | static_assert(test()); |
53 | |
54 | return 0; |
55 | } |
56 | |