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 // UNSUPPORTED: libcpp-has-no-incomplete-format 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> test(const CharT * fmt)23constexpr 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 test()37constexpr bool test() { 38 test("abc"); 39 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 40 test(L"abc"); 41 #endif 42 #ifndef TEST_HAS_NO_CHAR8_T 43 test(u8"abc"); 44 #endif 45 test(u"abc"); 46 test(U"abc"); 47 48 return true; 49 } 50 main(int,char **)51int main(int, char**) { 52 test(); 53 static_assert(test()); 54 55 return 0; 56 } 57