jbcoe / jbcoe/cc-protocol

Handle value category propagation

Open
#97 1 comment 0 reactions 1 assignee Claimed by @RyanJK5 View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.