[libcxx-commits] [libc] [libcxx] [llvm] [libcxx][libc] Hand in Hand PoC with from_chars (PR #91651)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 20 08:39:30 PDT 2024
================
@@ -0,0 +1,36 @@
+//===-- 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::shared {
+
+using internal::ExpandedFloat;
+using internal::RoundDirection;
+
+template <class T>
+inline internal::FloatConvertReturn<T>
+binary_exp_to_float(internal::ExpandedFloat<T> init_num, bool truncated,
+ internal::RoundDirection round) {
+ return internal::binary_exp_to_float(init_num, truncated, round);
+}
+
+template <class T>
+inline internal::FloatConvertReturn<T> decimal_exp_to_float(
+ internal::ExpandedFloat<T> init_num, bool truncated,
+ internal::RoundDirection round, const char *__restrict num_start,
+ const size_t num_len = cpp::numeric_limits<size_t>::max()) {
+ return internal::decimal_exp_to_float(init_num, truncated, round, num_start,
+ num_len);
+}
----------------
ldionne wrote:
IMO, we should only use `::shared::` in the declaration of these functions.
```suggestion
template <class T>
shared::FloatConvertReturn<T>
binary_exp_to_float(shared::ExpandedFloat<T> init_num, bool truncated,
shared::RoundDirection round) {
return internal::binary_exp_to_float(init_num, truncated, round);
}
template <class T>
shared::FloatConvertReturn<T> decimal_exp_to_float(
shared::ExpandedFloat<T> init_num, bool truncated,
shared::RoundDirection round, const char *__restrict num_start,
const size_t num_len = cpp::numeric_limits<size_t>::max()) {
return internal::decimal_exp_to_float(init_num, truncated, round, num_start,
num_len);
}
```
(no need for `inline` since it's a template)
https://github.com/llvm/llvm-project/pull/91651
More information about the libcxx-commits
mailing list