[libcxx-commits] [PATCH] D102135: [libcxx][ranges] adds _`copyable-box`_

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 2 08:14:26 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__ranges/copyable_box.h:130-131
+    // Implementation of assignment operators in case we perform optimization (1)
+    constexpr __copyable_box& operator=(__copyable_box const&) requires copyable<_Tp> = default;
+    constexpr __copyable_box& operator=(__copyable_box&&) requires movable<_Tp> = default;
+
----------------
tcanens wrote:
> The `constexpr` should be removed - on defaulted functions, an explicit `constexpr` is an assertion of constexpr-ness.
That is true for defaulted //comparison and relational// operators in C++20; it's never been true for defaulted special member functions. (And yes this is horrible and I'm pretty sure a defect report has been filed somewhere.)
https://godbolt.org/z/61e564vra

So this code is technically correct as written. But stylistically I agree: writing `constexpr` here is redundant and should be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102135



More information about the libcxx-commits mailing list