[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:29:59 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:
> Quuxplusone wrote:
> > 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.
> > 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
>
> That's not what https://timsong-cpp.github.io/cppwp/dcl.fct.def.default#3.sentence-1 says.
>
Hm. That sentence dates back at least to the beginning of the C++11 repository
https://github.com/cplusplus/draft/blob/d8fb8cf16dd05f711d33b3749a757d69068e45ef/source/declarators.tex#L2227-L2229
and yet no compiler has ever implemented it.
https://godbolt.org/z/3TozqePYx
Strange.
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