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, c++20 9 10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME 11 12 // <format> 13 14 // template<class charT, formattable<charT>... Ts> 15 // struct formatter<pair-or-tuple<Ts...>, charT> 16 17 // constexpr void constexpr void set_brackets(basic_string_view<charT> opening, 18 // basic_string_view<charT> closing) noexcept; 19 20 // Note this tests the basics of this function. It's tested in more detail in 21 // the format functions tests. 22 23 #include <format> 24 #include <tuple> 25 #include <utility> 26 27 #include "make_string.h" 28 29 #define SV(S) MAKE_STRING_VIEW(CharT, S) 30 31 template <class CharT, class Arg> 32 constexpr void test() { 33 std::formatter<Arg, CharT> formatter; 34 formatter.set_brackets(SV("open"), SV("close")); 35 // Note the SV macro may throw, so can't use it. 36 static_assert(noexcept(formatter.set_brackets(std::basic_string_view<CharT>{}, std::basic_string_view<CharT>{}))); 37 38 // Note there is no direct way to validate this function modified the object. 39 } 40 41 template <class CharT> 42 constexpr void test() { 43 test<CharT, std::tuple<int>>(); 44 test<CharT, std::tuple<int, CharT>>(); 45 test<CharT, std::pair<int, CharT>>(); 46 test<CharT, std::tuple<int, CharT, bool>>(); 47 } 48 49 constexpr bool test() { 50 test<char>(); 51 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 52 test<wchar_t>(); 53 #endif 54 55 return true; 56 } 57 58 int main(int, char**) { 59 test(); 60 static_assert(test()); 61 62 return 0; 63 } 64