C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal for Uniform Forward And Move

From: Jarrad Waterloo <descender76_at_[hidden]>
Date: Thu, 22 Jun 2023 08:20:55 -0400
What about just use the circle compiler move and forward keywords? That way
there is already a working implementation. As words it is better in line
other words we may add in the future. One off symbols are great but when
one have multiple related symbols that form a sort of vocabulary of their
own, words are more pleasant.

On Thu, Jun 22, 2023 at 4:24 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> On Thu, Jun 22, 2023 at 7:40 AM Timur Doumler via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> > `name(name&&)` can now mean either a function type: `type(type&&)` or a
> function call with a forwarded parameter.
>
> A function call with a forwarded parameter would be:
>
> void SomeFunc(int&&) {}
>
> int main(void)
> {
> int monkey = 7;
> SomeFunc(move(monkey));
> //or:
> SomeFunc(monkey&&); // not there is no 'void' here
> }
>
> And a function declaration would be:
>
> void SomeFunc(int&&) {}
>
> int main(void)
> {
> typedef int monkey;
> void SomeFunc(monkey&&); // Note that this has 'void' at the
> beginning
> }
>
> I think the parser can easily see that the latter example begins with
> "void", and can thus disambiguate easily.
>
> Another one to consider is:
>
> std::function< something(something&&) >
>
> If the template is expecting a type parameter rather than a value
> parameter, then it's easy to disambiguate. If there is more than one
> template overload, and if one can take a type, and another can take a
> value, then it would only be tricky if 'something' were the name of a
> class with a constexpr constructor.
>
> class Monkey { constexpr Monkey(void) {} };
>
> some_template< Monkey(int&&) > my_object;
>
> Actually I just realised that we already have this 'problem' in the
> language, and I think it's only 'std::function' that's affected
> because it cannot be implemented without compiler support.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-06-22 12:21:08