C++ Logo

std-proposals

Advanced search

[std-proposals] p3039r1 proxy temporary objects

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Fri, 20 Feb 2026 19:39:07 +0100
Paper suggests rewriting `ptr->meber` by `(*ptr).member`.

But this creates an interesting case, new `->` created this way will
have capabilities impossible compared to manually written `->`.

Consider example:
```
const auto& foo = ptr->member;
```
and `ptr` that has a `*` returning proxy value.
With this rewrite, the lifetime of the proxy object will be expanded
to the lifetime of the `foo` reference.
Using user defined `->` you can't in anyway do this as this operator
is required to return pointer and not value (as it will call nested of `->`).

This is expected behavior? If yes then maybe we should
discourage of further use of user defined `->` operator?

Received on 2026-02-20 18:39:21