[libcxx-commits] [libcxx] WIP [libc++][format] Partial P3391R2: `constexpr` `std::format` (PR #230239)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 14 00:08:23 PDT 2026


================
@@ -492,10 +502,15 @@ template <class _CharT>
 // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
 // fires too eagerly, see http://llvm.org/PR61563.
 template <class = void>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {
-  auto __result = __format::__try_constant_folding(__fmt, __args);
-  if (__result.has_value())
-    return *std::move(__result);
+[[nodiscard]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
+vformat(string_view __fmt, format_args __args) {
+  // P3391R2: We don't need constant folding runtime optimizations in the scope of a constant evaluation.
+  // `if !consteval` is only present since C++23, so we use !__libcpp_is_constant_evaluated().
----------------
Zingam wrote:

```suggestion
```

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


More information about the libcxx-commits mailing list