1 //===-- A data structure for str_to_number to return ------------*- C++ -*-===//
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 #ifndef LLVM_LIBC_SUPPORT_STR_TO_NUM_RESULT_H
10 #define LLVM_LIBC_SUPPORT_STR_TO_NUM_RESULT_H
14 namespace __llvm_libc
{
16 template <typename T
> struct StrToNumResult
{
21 constexpr StrToNumResult(T value
) : value(value
), error(0), parsed_len(0) {}
22 constexpr StrToNumResult(T value
, ptrdiff_t parsed_len
)
23 : value(value
), error(0), parsed_len(parsed_len
) {}
24 constexpr StrToNumResult(T value
, ptrdiff_t parsed_len
, int error
)
25 : value(value
), error(error
), parsed_len(parsed_len
) {}
27 constexpr bool has_error() { return error
!= 0; }
29 constexpr operator T() { return value
; }
31 } // namespace __llvm_libc
33 #endif // LLVM_LIBC_SUPPORT_STR_TO_NUM_RESULT_H