protocol already propagates const-ness: that is, a const protocol<I> 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?
struct Interface {
int foo() &&;
int bar() &;
};
struct A {
int foo() && { return 1; }
int bar() & { return 2; }
};
protocol<Interface> p{A{}};
p.bar(); // OK
protocol<Interface>{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.
protocolalready propagates const-ness: that is, aconst protocol<I>implies that only theconstmembers ofIcan be used.An extension of this is propagating the object's value category, i.e. lvalue or rvalue. How should the following behave?
From an implementation perspective, this would require adding overloads to
named_forwarder, and require carefully persistingT&/T&&throughout.This should probably be acknowledged in the draft, but the feature itself could potentially be deferred to a later extension of
protocol.