-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libcxx][libc] Hand in Hand PoC with from_chars #91651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Floating point number utils -----------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SHARED_FP_BITS_H | ||
#define LLVM_LIBC_SHARED_FP_BITS_H | ||
|
||
#include "src/__support/FPUtil/FPBits.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
namespace shared { | ||
|
||
using fputil::FPBits; | ||
|
||
} // namespace shared | ||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SHARED_FP_BITS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//===-- String to float conversion utils ------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SHARED_STR_TO_FLOAT_H | ||
#define LLVM_LIBC_SHARED_STR_TO_FLOAT_H | ||
|
||
#include "src/__support/str_to_float.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
namespace shared { | ||
|
||
using internal::ExpandedFloat; | ||
using internal::FloatConvertReturn; | ||
using internal::RoundDirection; | ||
|
||
using internal::binary_exp_to_float; | ||
using internal::decimal_exp_to_float; | ||
|
||
} // namespace shared | ||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SHARED_STR_TO_FLOAT_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//===-- String to int conversion utils --------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SHARED_STR_TO_INTEGER_H | ||
#define LLVM_LIBC_SHARED_STR_TO_INTEGER_H | ||
|
||
#include "src/__support/str_to_integer.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
namespace shared { | ||
|
||
using LIBC_NAMESPACE::StrToNumResult; | ||
|
||
using internal::strtointeger; | ||
|
||
} // namespace shared | ||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SHARED_STR_TO_INTEGER_H |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -71,7 +71,7 @@ | |||||
"`P0394R4 <https://wg21.link/P0394R4>`__","Hotel Parallelifornia: terminate() for Parallel Algorithms Exception Handling","2016-06 (Oulu)","|Complete|","17.0","" | ||||||
"","","","","","" | ||||||
"`P0003R5 <https://wg21.link/P0003R5>`__","Removing Deprecated Exception Specifications from C++17","2016-11 (Issaquah)","|Complete|","5.0","" | ||||||
"`P0067R5 <https://wg21.link/P0067R5>`__","Elementary string conversions, revision 5","2016-11 (Issaquah)","|Partial|","","``std::(to|from)_chars`` for integrals has been available since version 7.0. ``std::to_chars`` for ``float`` and ``double`` since version 14.0 ``std::to_chars`` for ``long double`` uses the implementation for ``double``." | ||||||
"`P0067R5 <https://wg21.link/P0067R5>`__","Elementary string conversions, revision 5","2016-11 (Issaquah)","|Partial|","","``std::(to|from)_chars`` for integrals has been available since version 7.0. ``std::to_chars`` for ``float`` and ``double`` since version 14.0 ``std::to_chars`` for ``long double`` uses the implementation for ``double``. ``std::from_chars`` for ``float`` and ``double`` since version 20.0." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reattaching my suggestion (clarify what's done resp. still open) after the table format changed to include notes.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I typed a comment before, but it seems I forgot to publish it :-/ I'm open to suggestions to improve the wording, feel free to prove and updated wording. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, thanks for the clarification - just to double-check though:
This PR is adding |
||||||
"`P0403R1 <https://wg21.link/P0403R1>`__","Literal suffixes for ``basic_string_view``\ ","2016-11 (Issaquah)","|Complete|","4.0","" | ||||||
"`P0414R2 <https://wg21.link/P0414R2>`__","Merging shared_ptr changes from Library Fundamentals to C++17","2016-11 (Issaquah)","|Complete|","11.0","" | ||||||
"`P0418R2 <https://wg21.link/P0418R2>`__","Fail or succeed: there is no atomic lattice","2016-11 (Issaquah)","","","" | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// -*- C++ -*- | ||
ldionne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H | ||
#define _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H | ||
|
||
#include <__assert> | ||
#include <__charconv/chars_format.h> | ||
#include <__charconv/from_chars_result.h> | ||
#include <__config> | ||
#include <__system_error/errc.h> | ||
#include <cstddef> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_PUSH_MACROS | ||
#include <__undef_macros> | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER >= 17 | ||
|
||
template <class _Fp> | ||
struct __from_chars_result { | ||
_Fp __value; | ||
ptrdiff_t __n; | ||
errc __ec; | ||
}; | ||
|
||
template <class _Fp> | ||
_LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point( | ||
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt); | ||
|
||
extern template __from_chars_result<float> __from_chars_floating_point( | ||
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt); | ||
|
||
extern template __from_chars_result<double> __from_chars_floating_point( | ||
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt); | ||
|
||
template <class _Fp> | ||
_LIBCPP_HIDE_FROM_ABI from_chars_result | ||
__from_chars(const char* __first, const char* __last, _Fp& __value, chars_format __fmt) { | ||
__from_chars_result<_Fp> __r = std::__from_chars_floating_point<_Fp>(__first, __last, __fmt); | ||
if (__r.__ec != errc::invalid_argument) | ||
__value = __r.__value; | ||
return {__first + __r.__n, __r.__ec}; | ||
} | ||
|
||
_LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result | ||
from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) { | ||
return std::__from_chars<float>(__first, __last, __value, __fmt); | ||
} | ||
|
||
_LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result | ||
from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) { | ||
return std::__from_chars<double>(__first, __last, __value, __fmt); | ||
} | ||
|
||
#endif // _LIBCPP_STD_VER >= 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
_LIBCPP_POP_MACROS | ||
|
||
#endif // _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H |
Uh oh!
There was an error while loading. Please reload this page.