[libcxx-commits] [libcxx] [libc++] Add basic constant folding for std::format (PR #107197)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 27 08:26:25 PST 2025
================
@@ -463,9 +496,13 @@ template <class = void>
template <class = void>
[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
vformat(wstring_view __fmt, wformat_args __args) {
- wstring __res;
- std::vformat_to(std::back_inserter(__res), __fmt, __args);
- return __res;
+ return std::__try_constant_folding(__fmt, __args)
+ .or_else([&]() -> optional<wstring> {
----------------
philnik777 wrote:
This isn't relevant anymore for the generic implementation and the constant folding definitely has good code gen right now, so I don't think this is a problem. I've also never seen a case where moving a string caused significant amounts of code gen.
https://github.com/llvm/llvm-project/pull/107197
More information about the libcxx-commits
mailing list