1// Copyright 2023 Matt Borland
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#ifndef BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP
6#define BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP
7
8#include <system_error>
9
10namespace boost { namespace charconv {
11
12// 22.13.3, Primitive numerical input conversion
13
14template <typename UC>
15struct from_chars_result_t
16{
17 const UC* ptr;
18
19 // Values:
20 // 0 = no error
21 // EINVAL = invalid_argument
22 // ERANGE = result_out_of_range
23 std::errc ec;
24
25 friend constexpr bool operator==(const from_chars_result_t<UC>& lhs, const from_chars_result_t<UC>& rhs) noexcept
26 {
27 return lhs.ptr == rhs.ptr && lhs.ec == rhs.ec;
28 }
29
30 friend constexpr bool operator!=(const from_chars_result_t<UC>& lhs, const from_chars_result_t<UC>& rhs) noexcept
31 {
32 return !(lhs == rhs); // NOLINT : Expression can not be simplified since this is the definition
33 }
34
35 constexpr explicit operator bool() const noexcept { return ec == std::errc{}; }
36};
37using from_chars_result = from_chars_result_t<char>;
38
39}} // Namespaces
40
41#endif // BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP
42

source code of boost/libs/charconv/include/boost/charconv/detail/from_chars_result.hpp