[libcxx-commits] [libcxx] [libc++][format] Decay character arrays in formatting (PR #116571)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 21 03:14:50 PST 2024


================
@@ -188,15 +182,8 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu
   else if constexpr (__arg == __arg_t::__unsigned_long_long)
     return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};
   else if constexpr (__arg == __arg_t::__string_view)
-    // Using std::size on a character array will add the NUL-terminator to the size.
-    if constexpr (is_array_v<_Dp>)
-      return basic_format_arg<_Context>{
-          __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<_Dp> - 1}};
----------------
frederick-vs-ja wrote:

It seems that we can still handle character arrays as `basic_string_view` provided `extent_v<_Dp> - 1` is replaced with the correct length. Is such method more preferred? @mordante 

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


More information about the libcxx-commits mailing list