//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // libc++ supports basic_format_string in C++20 as an extension // UNSUPPORTED: !stdlib=libc++ && c++20 // // template // class basic_format_string...> // // constexpr basic_string_view get() const noexcept { return str; } #include #include #include #include #include "test_macros.h" #include "make_string.h" #define CSTR(S) MAKE_CSTRING(CharT, S) #define SV(S) MAKE_STRING_VIEW(CharT, S) template constexpr bool test() { assert((std::basic_format_string{CSTR("foo")}.get() == SV("foo"))); assert((std::basic_format_string{CSTR("{}")}.get() == SV("{}"))); assert((std::basic_format_string{CSTR("{} {:*>6}")}.get() == SV("{} {:*>6}"))); // Embedded NUL character assert((std::basic_format_string{SV("{}\0{}")}.get() == SV("{}\0{}"))); return true; } int main(int, char**) { test(); static_assert(test()); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); static_assert(test()); #endif return 0; }