Handle value category propagation
- Dominant language
- C++
- Stars
- 11
- Forks
- 4
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 131
Description
`protocol` already propagates const-ness: that is, a `const protocol` implies that only the `const` members of `I` can be used.
An extension of this is propagating the object's value category, i.e. lvalue or rvalue. How should the following behave?
```c++
struct Interface {
int foo() &&;
int bar() &;
};
struct A {
int foo() && { return 1; }
int bar() & { return 2; }
};
protocol p{A{}};
p.bar(); // OK
protocol{A{}}.foo(); // OK?
p.foo(); // ERROR?
std::move(p).bar(); // ERROR?
```
From an implementation perspective, this would require adding overloads to `named_forwarder`, and require carefully persisting `T&` / `T&&` throughout.
This should probably be acknowledged in the draft, but the feature itself could potentially be deferred to a later extension of `protocol`.
Contributor guide
Assessment
This issue has not been assessed yet.