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
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
14 // template<class charT, formattable<charT>... Ts>
15 // struct formatter<pair-or-tuple<Ts...>, charT>
17 // constexpr void constexpr void set_brackets(basic_string_view<charT> opening,
18 // basic_string_view<charT> closing) noexcept;
20 // Note this tests the basics of this function. It's tested in more detail in
21 // the format functions tests.
27 #include "make_string.h"
29 #define SV(S) MAKE_STRING_VIEW(CharT, S)
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
>{})));
38 // Note there is no direct way to validate this function modified the object.
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>>();
49 constexpr bool test() {
51 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
58 int main(int, char**) {
60 static_assert(test());