xref: /llvm-project/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 // <system_error>
10 
11 // class error_code
12 
13 // explicit operator bool() const;
14 
15 #include <system_error>
16 #include <string>
17 #include <cassert>
18 
19 int main()
20 {
21     {
22         const std::error_code ec(6, std::generic_category());
23         assert(static_cast<bool>(ec));
24     }
25     {
26         const std::error_code ec(0, std::generic_category());
27         assert(!static_cast<bool>(ec));
28     }
29 }
30