[libcxx-commits] [PATCH] D112017: [libcxx][format] Fix how we handle char traits in formatter<string> and formatter<string_view>

Daniel McIntosh via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 18 14:16:03 PDT 2021


DanielMcIntosh-IBM added inline comments.


================
Comment at: libcxx/include/__format/formatter.h:184-186
+template <class _CharT, class _Traits, class _Fill>
+_LIBCPP_HIDE_FROM_ABI auto __write_unicode(output_iterator<const _CharT&> auto __out_it,
+                                           basic_string_view<_CharT, _Traits> __str, ptrdiff_t __width,
----------------
vitaut wrote:
> I don't think traits are needed in this internal function. It might be better to convert `basic_string_view<_CharT, _Traits>` into `basic_string_view<_CharT>` when calling it and remove `_Traits` here to prevent template bloat.
If my understanding of templates is correct, when `_Traits != char_traits<_CharT>`, then `basic_string_view<_CharT, _Traits>` is a totally different type from `basic_string_view<_CharT> == basic_string_view<_CharT, char_traits<_CharT>>`, and may not be convertible to `basic_string_view<_CharT>`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112017/new/

https://reviews.llvm.org/D112017



More information about the libcxx-commits mailing list