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 from_chars_result
14 // constexpr explicit operator bool() const noexcept { return ec == errc{}; }
19 #include <system_error>
20 #include <type_traits>
22 #include "test_macros.h"
24 static_assert(!std::is_convertible_v
<std::from_chars_result
, bool>);
25 static_assert(std::is_constructible_v
<bool, std::from_chars_result
>);
27 constexpr bool test() {
30 std::from_chars_result value
{nullptr, std::errc
{}};
31 assert(bool(value
) == true);
32 static_assert(noexcept(bool(value
)) == true);
36 std::from_chars_result value
{nullptr, std::errc::value_too_large
};
37 assert(bool(value
) == false);
38 static_assert(noexcept(bool(value
)) == true);
44 int main(int, char**) {
46 static_assert(test());