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 | |
10 | // <format> |
11 | |
12 | // explicit operator bool() const noexcept |
13 | // |
14 | // Note more testing is done in the unit test for: |
15 | // template<class Visitor, class Context> |
16 | // see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); |
17 | |
18 | #include <format> |
19 | #include <cassert> |
20 | #include <type_traits> |
21 | |
22 | #include "test_macros.h" |
23 | |
24 | template <class CharT> |
25 | void test() { |
26 | using Context = std::basic_format_context<CharT*, CharT>; |
27 | { |
28 | std::basic_format_arg<Context> format_arg{}; |
29 | ASSERT_NOEXCEPT(!format_arg); |
30 | assert(!format_arg); |
31 | ASSERT_NOEXCEPT(static_cast<bool>(format_arg)); |
32 | assert(!static_cast<bool>(format_arg)); |
33 | } |
34 | } |
35 | |
36 | int main(int, char**) { |
37 | test<char>(); |
38 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
39 | test<wchar_t>(); |
40 | #endif |
41 | |
42 | return 0; |
43 | } |
44 | |