[ELF] Avoid make in elf::writeARMCmseImportLib
[llvm-project.git] / libc / src / __support / str_to_num_result.h
blob48c363c88ff419d17b57abc0cecd46d59d13d7f1
1 //===-- A data structure for str_to_number to return ------------*- C++ -*-===//
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 // -----------------------------------------------------------------------------
10 // **** WARNING ****
11 // This file is shared with libc++. You should also be careful when adding
12 // dependencies to this file, since it needs to build for all libc++ targets.
13 // -----------------------------------------------------------------------------
15 #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
16 #define LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
18 #include "src/__support/macros/attributes.h" // LIBC_INLINE
19 #include "src/__support/macros/config.h"
21 #include <stddef.h>
23 namespace LIBC_NAMESPACE_DECL {
25 // -----------------------------------------------------------------------------
26 // **** WARNING ****
27 // This interface is shared with libc++, if you change this interface you need
28 // to update it in both libc and libc++.
29 // -----------------------------------------------------------------------------
30 template <typename T> struct StrToNumResult {
31 T value;
32 int error;
33 ptrdiff_t parsed_len;
35 LIBC_INLINE constexpr StrToNumResult(T value)
36 : value(value), error(0), parsed_len(0) {}
37 LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len)
38 : value(value), error(0), parsed_len(parsed_len) {}
39 LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len, int error)
40 : value(value), error(error), parsed_len(parsed_len) {}
42 LIBC_INLINE constexpr bool has_error() { return error != 0; }
44 LIBC_INLINE constexpr operator T() { return value; }
46 } // namespace LIBC_NAMESPACE_DECL
48 #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H