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

source code of libcxx/test/std/utilities/format/format.arguments/format.arg/operator_bool.pass.cpp