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