[libcxx-commits] [PATCH] D127570: [libc++][format] Use forwarding references.

Victor Zverovich via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 25 07:06:18 PDT 2022


vitaut added inline comments.


================
Comment at: libcxx/include/__format/format_arg.h:213-214
   _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {}
-  _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept : __handle_(__value) {}
+  _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle&& __value) noexcept
+      : __handle_(std::forward<__handle>(__value)) {}
 };
----------------
Why pass `__handle` by rvalue or call forward here? Note that handle is just a pair of pointers so it probably makes more sense to pass it by value as before.


================
Comment at: libcxx/test/std/utilities/format/format.functions/P2418.pass.cpp:31
+struct std::formatter<MoveOnly, CharT> : std::formatter<int, CharT> {
+  auto format(const MoveOnly& m, auto& ctx) -> decltype(ctx.out()) {
+    return std::formatter<int, CharT>::format(m.get(), ctx);
----------------
`format` should be const.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127570



More information about the libcxx-commits mailing list