| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP_CHARCONV |
| 11 |
#define _LIBCPP_CHARCONV |
| 12 |
|
| 13 |
/* |
| 14 |
charconv synopsis |
| 15 |
|
| 16 |
namespace std { |
| 17 |
|
| 18 |
// floating-point format for primitive numerical conversion |
| 19 |
enum class chars_format { |
| 20 |
scientific = unspecified, |
| 21 |
fixed = unspecified, |
| 22 |
hex = unspecified, |
| 23 |
general = fixed | scientific |
| 24 |
}; |
| 25 |
|
| 26 |
// 23.20.2, primitive numerical output conversion |
| 27 |
struct to_chars_result { |
| 28 |
char* ptr; |
| 29 |
errc ec; |
| 30 |
friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20 |
| 31 |
constexpr explicit operator bool() const noexcept { return ec == errc{}; } // since C++26 |
| 32 |
}; |
| 33 |
|
| 34 |
constexpr to_chars_result to_chars(char* first, char* last, see below value, |
| 35 |
int base = 10); // constexpr since C++23 |
| 36 |
to_chars_result to_chars(char* first, char* last, bool value, |
| 37 |
int base = 10) = delete; |
| 38 |
|
| 39 |
to_chars_result to_chars(char* first, char* last, float value); |
| 40 |
to_chars_result to_chars(char* first, char* last, double value); |
| 41 |
to_chars_result to_chars(char* first, char* last, long double value); |
| 42 |
|
| 43 |
to_chars_result to_chars(char* first, char* last, float value, |
| 44 |
chars_format fmt); |
| 45 |
to_chars_result to_chars(char* first, char* last, double value, |
| 46 |
chars_format fmt); |
| 47 |
to_chars_result to_chars(char* first, char* last, long double value, |
| 48 |
chars_format fmt); |
| 49 |
|
| 50 |
to_chars_result to_chars(char* first, char* last, float value, |
| 51 |
chars_format fmt, int precision); |
| 52 |
to_chars_result to_chars(char* first, char* last, double value, |
| 53 |
chars_format fmt, int precision); |
| 54 |
to_chars_result to_chars(char* first, char* last, long double value, |
| 55 |
chars_format fmt, int precision); |
| 56 |
|
| 57 |
// 23.20.3, primitive numerical input conversion |
| 58 |
struct from_chars_result { |
| 59 |
const char* ptr; |
| 60 |
errc ec; |
| 61 |
friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20 |
| 62 |
constexpr explicit operator bool() const noexcept { return ec == errc{}; } // since C++26 |
| 63 |
}; |
| 64 |
|
| 65 |
constexpr from_chars_result from_chars(const char* first, const char* last, |
| 66 |
see below& value, int base = 10); // constexpr since C++23 |
| 67 |
|
| 68 |
} // namespace std |
| 69 |
|
| 70 |
*/ |
| 71 |
|
| 72 |
#include <__config> |
| 73 |
|
| 74 |
#if _LIBCPP_STD_VER >= 17 |
| 75 |
# include <__charconv/chars_format.h> |
| 76 |
# include <__charconv/from_chars_integral.h> |
| 77 |
# include <__charconv/from_chars_result.h> |
| 78 |
# include <__charconv/tables.h> |
| 79 |
# include <__charconv/to_chars.h> |
| 80 |
# include <__charconv/to_chars_base_10.h> |
| 81 |
# include <__charconv/to_chars_floating_point.h> |
| 82 |
# include <__charconv/to_chars_integral.h> |
| 83 |
# include <__charconv/to_chars_result.h> |
| 84 |
# include <__charconv/traits.h> |
| 85 |
#endif // _LIBCPP_STD_VER >= 17 |
| 86 |
|
| 87 |
#include <version> |
| 88 |
|
| 89 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 90 |
# pragma GCC system_header |
| 91 |
#endif |
| 92 |
|
| 93 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 94 |
|
| 95 |
_LIBCPP_END_NAMESPACE_STD |
| 96 |
|
| 97 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 |
| 98 |
# include <cerrno> |
| 99 |
# include <cstddef> |
| 100 |
# include <initializer_list> |
| 101 |
# include <new> |
| 102 |
#endif |
| 103 |
|
| 104 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 105 |
# include <cmath> |
| 106 |
# include <concepts> |
| 107 |
# include <cstdint> |
| 108 |
# include <cstdlib> |
| 109 |
# include <cstring> |
| 110 |
# include <iosfwd> |
| 111 |
# include <limits> |
| 112 |
# include <type_traits> |
| 113 |
#endif |
| 114 |
|
| 115 |
#endif // _LIBCPP_CHARCONV |