[libcxx-commits] [PATCH] D97443: [libcxx] adds concept std::copyable
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 6 10:08:32 PST 2021
Quuxplusone added inline comments.
================
Comment at: libcxx/test/std/concepts/object/copyable.h:34
+ no_const_value_assignment&
+ operator=(no_const_value_assignment const) = delete;
+};
----------------
cjdb wrote:
> Quuxplusone wrote:
> > The `const` keyword on a by-value function parameter is meaningless; please remove it. (And then rename to `no_assignment`.)
> > I don't intuitively understand what overload set is expected here. Do you expect there to be a defaulted `operator=(const T&)` and/or `operator=(T&&)`? (I think there won't be.)
> This was supposed to test the requirement `assignable_from<T&, const T>`, but now that you point it out, I'm not sure how to test that in isolation of the other requirements.
I believe the library often uses `const T` when it means `const T&&`. (For example, `forward<T>` means `forward<T&&>`; `declval<T>` means `declval<T&&>`; etc.) Assuming the same holds true here, you could do a struct with an overload set like
```
struct deleted_assignment_from_const_rvalue {
deleted_assignment_from_const_rvalue& operator=(const deleted_assignment_from_const_rvalue&);
deleted_assignment_from_const_rvalue& operator=(deleted_assignment_from_const_rvalue&&);
deleted_assignment_from_const_rvalue& operator=(const deleted_assignment_from_const_rvalue&&) = delete;
};
static_assert(!std::assignable<deleted_assignment_from_const_rvalue&, const deleted_assignment_from_const_rvalue>);
static_assert(!std::copyable<deleted_assignment_from_const_rvalue>);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97443/new/
https://reviews.llvm.org/D97443
More information about the libcxx-commits
mailing list