1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
13 // struct to_chars_result
14 // constexpr explicit operator bool() const noexcept { return ec == errc{}; }
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() {
29 std::to_chars_result value
{nullptr, std::errc
{}};
30 assert(bool(value
) == true);
31 static_assert(noexcept(bool(true)) == true);
35 std::to_chars_result value
{nullptr, std::errc::value_too_large
};
36 assert(bool(value
) == false);
37 static_assert(noexcept(bool(true)) == true);
43 int main(int, char**) {
45 static_assert(test());