[libcxx-commits] [PATCH] D156609: [libc++][print] Adds ostream overloads.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 30 12:55:07 PDT 2023


Mordante added inline comments.


================
Comment at: libcxx/include/ostream:154
 template<class traits>
 basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete;       // since C++20
 template<class traits>
----------------
ldionne wrote:
> General question: do we follow this recommended practice? https://eel.is/c++draft/ostream.formatted.print#4
> 
> > Recommended practice: For vprint_unicode, if invoking the native Unicode API requires transcoding, implementations should substitute invalid code units with U+FFFD REPLACEMENT CHARACTER per the Unicode Standard, Chapter 3.9 U+FFFD Substitution in Conversion.
Yes we do, this is tested in earlier patches
test/libcxx/input.output/iostream.format/print.fun/transcoding.pass.cpp
test/libcxx/input.output/iostream.format/print.fun/vprint_unicode_windows.pass.cpp


================
Comment at: libcxx/include/print:203
+  // the behavior in the test. This is not part of the public API.
+#  ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
+  return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);
----------------
ldionne wrote:
> Can you explain why this macro is necessary? How did you handle testing the previous `print` code without having to introduce this macro?
In the other tests I found ways around by calling implementation specific functions from `test/libcxx`. Here that's not possible.


================
Comment at: libcxx/modules/std/ostream.inc:31-35
   using std::print;
   using std::println;
 
   using std::vprint_nonunicode;
   using std::vprint_unicode;
----------------
Zingam wrote:
> I just skimmed over this patch out of curiosity. Shouldn't these be guarded against C++23 like in print.inc?
Yes they should. When I wrote this patch we didn't allow the std module in C++20 so it was not needed. But now we support them in C++20, thanks for catching this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156609



More information about the libcxx-commits mailing list