File indexing completed on 2026-05-03 08:13:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H
0011 #define _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H
0012
0013 #include <__assert>
0014 #include <__charconv/chars_format.h>
0015 #include <__charconv/from_chars_result.h>
0016 #include <__config>
0017 #include <__cstddef/ptrdiff_t.h>
0018 #include <__system_error/errc.h>
0019
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 #endif
0023
0024 _LIBCPP_PUSH_MACROS
0025 #include <__undef_macros>
0026
0027 _LIBCPP_BEGIN_NAMESPACE_STD
0028
0029 #if _LIBCPP_STD_VER >= 17
0030
0031 template <class _Fp>
0032 struct __from_chars_result {
0033 _Fp __value;
0034 ptrdiff_t __n;
0035 errc __ec;
0036 };
0037
0038 template <class _Fp>
0039 _LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point(
0040 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
0041
0042 extern template __from_chars_result<float> __from_chars_floating_point(
0043 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
0044
0045 extern template __from_chars_result<double> __from_chars_floating_point(
0046 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
0047
0048 template <class _Fp>
0049 _LIBCPP_HIDE_FROM_ABI from_chars_result
0050 __from_chars(const char* __first, const char* __last, _Fp& __value, chars_format __fmt) {
0051 __from_chars_result<_Fp> __r = std::__from_chars_floating_point<_Fp>(__first, __last, __fmt);
0052 if (__r.__ec != errc::invalid_argument)
0053 __value = __r.__value;
0054 return {__first + __r.__n, __r.__ec};
0055 }
0056
0057 _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result
0058 from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) {
0059 return std::__from_chars<float>(__first, __last, __value, __fmt);
0060 }
0061
0062 _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result
0063 from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) {
0064 return std::__from_chars<double>(__first, __last, __value, __fmt);
0065 }
0066
0067 #endif
0068
0069 _LIBCPP_END_NAMESPACE_STD
0070
0071 _LIBCPP_POP_MACROS
0072
0073 #endif