[libc-commits] [libc] [libcxx] [llvm] [libcxx][libc] Hand in Hand PoC with from_chars (PR #91651)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Sep 3 13:14:32 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);
+}
----------------
michaelrj-google wrote:

I went with just the `using` declaration like @mordante suggested, since it's simpler. We can change it back if we need a different interface.

https://github.com/llvm/llvm-project/pull/91651


More information about the libc-commits mailing list