C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit modifier for R-value references

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Mon, 19 Jun 2023 09:04:39 -0400
On Mon, Jun 19, 2023 at 8:57 AM Ville Voutilainen via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Mon, 19 Jun 2023 at 14:28, Edward Catmur via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
> >>
> >> template<typename T>
> >> void SetVector( T &&explicit arg ) {
> >> static T obj;
> >> vec = arg; // no need for 'forward' here
> >> }
> >
> >
> > That sounds feasible, and moderately useful. It wouldn't change the
> type, correct (and especially not the function type)? - it would just
> change the result of the value category computed by
> http://eel.is/c++draft/expr.prim.id#unqual-3.sentence-6 .
> [...]
> I completely fail to see what is "explicit" about any of this. It's
> the polar opposite of explicit.


Hear, hear; +1 what Ville said.
Also, Ed, IIRC ;) you have an extremely active proposal for
    void SetVector(vector<int>&& arg) {
        vec = reloc arg; // ta-da
    }
    template<class T>
    void SetVector(T&& arg) {
        vec = reloc arg; // ta-da
    }
to do exactly what OP wanted, and (1) with less syntax, (2) with the sigil
`reloc` appearing at the point of the move/forward/relocation, instead of
spookily at a distance. I don't see why you *in particular* would want this
kind of implicit double-move-bug factory in addition to that other safer
mechanism.

–Arthur

Received on 2023-06-19 13:04:53