Skip to content

Handle value category propagation #97

Description

@RyanJK5

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions