Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / charconv / charconv.syn / to_chars_result.operator_bool.pass.cpp
blobef9364d3a6470970daa9f6bbd94c4c69b6f00fc1
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
11 // <charconv>
13 // struct to_chars_result
14 // constexpr explicit operator bool() const noexcept { return ec == errc{}; }
16 #include <charconv>
18 #include <cassert>
19 #include <type_traits>
21 #include "test_macros.h"
23 static_assert(!std::is_convertible_v<std::to_chars_result, bool>);
24 static_assert(std::is_constructible_v<bool, std::to_chars_result>);
26 constexpr bool test() {
27 // True
29 std::to_chars_result value{nullptr, std::errc{}};
30 assert(bool(value) == true);
31 static_assert(noexcept(bool(true)) == true);
33 // False
35 std::to_chars_result value{nullptr, std::errc::value_too_large};
36 assert(bool(value) == false);
37 static_assert(noexcept(bool(true)) == true);
40 return true;
43 int main(int, char**) {
44 assert(test());
45 static_assert(test());
47 return 0;