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 | // struct format_to_n_result |
14 | |
15 | // [format.syn]/1 |
16 | // The class template format_to_n_result has the template parameters, data |
17 | // members, and special members specified above. It has no base classes or |
18 | // members other than those specified. |
19 | |
20 | #include <format> |
21 | |
22 | #include <cassert> |
23 | #include <concepts> |
24 | #include <iterator> |
25 | |
26 | #include "test_macros.h" |
27 | |
28 | template <class CharT> |
29 | constexpr void test() { |
30 | std::format_to_n_result<CharT*> v{nullptr, std::iter_difference_t<CharT*>{42}}; |
31 | |
32 | auto [out, size] = v; |
33 | static_assert(std::same_as<decltype(out), CharT*>); |
34 | assert(out == v.out); |
35 | static_assert(std::same_as<decltype(size), std::iter_difference_t<CharT*>>); |
36 | assert(size == v.size); |
37 | } |
38 | |
39 | constexpr bool test() { |
40 | test<char>(); |
41 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
42 | test<wchar_t>(); |
43 | #endif |
44 | return true; |
45 | } |
46 | |
47 | int main(int, char**) { |
48 | assert(test()); |
49 | static_assert(test()); |
50 | |
51 | return 0; |
52 | } |
53 | |