Date: Sun, 8 Jan 2023 13:45:56 -0500
On 1/8/23 08:41, Guillaume Racicot via Std-Proposals wrote:
> Be mindful though that a prvalue is different from an xvalue. Copy
> elision and direct initialization cannot happen with calls to std::move,
> whereas it is permitted with prvalue. If you have a source to source
> compiler you will have to take that into account to not break code, and
> you will have to only generate std::move when the expression would be an
> lvalue.
Yeah I can do that as well, and it would convey with the C++ standards
better.
>
> Here's an example of a non-copiable non-movable type passed in parameter
> by value:
>
> void do_thing_with_mutex(std::mutex);
>
> do_thing_with_mutex(std::mutex{});
>
> If you call std::move on that prvalue, the code will be ill-formed since
> the compiler would be forced to call the move constructor.
Thanks for the head's up.
> It may look like details, but those are important details because you
> might accidentally propose things that will break people and hinder
> performance.
>
> Em sáb., 7 de jan. de 2023 16:44, Phil Bouchard via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> escreveu:
>
>
>
> On 1/7/23 03:35, Peter Olsson via Std-Proposals wrote:
> >> a.foo(move(list<int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
> >
> >> foo(move(ostream()));
> >
> > Do you realize that using std::move on a temporary like this is
> pretty
> > pointless because it's already an rvalue?
>
> I was referring to the automatic generated code by the source-to-source
> compiler. Whether it's a r-value and l-value, a move() will be
> generated.
>
>
> --
> Logo <https://www.fornux.com/ <https://www.fornux.com/>>
> *Phil Bouchard* facebook icon
> <https://www.linkedin.com/in/phil-bouchard-5723a910/
> <https://www.linkedin.com/in/phil-bouchard-5723a910/>>
> CTO
> T: (819) 328-4743
> E: phil_at_[hidden] <mailto:phil_at_[hidden]>| www.fornux.com
> <http://www.fornux.com> <http://www.fornux.com <http://www.fornux.com>>
> 8 rue de la Baie| Gatineau (Qc), J8T 3H3 Canada
>
> Banner <https://goglobalawards.org/ <https://goglobalawards.org/>>
> Le message ci-dessus, ainsi que les
> documents l'accompagnant, sont destinés uniquement aux personnes
> identifiées et peuvent contenir des informations privilégiées,
> confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce
> message par erreur, veuillez le détruire.
> This communication (and/or the attachments) is intended for named
> recipients only and may contain privileged or confidential information
> which is not to be disclosed. If you received this communication by
> mistake please destroy all copies.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden] <mailto:Std-Proposals_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
>
>
> Be mindful though that a prvalue is different from an xvalue. Copy
> elision and direct initialization cannot happen with calls to std::move,
> whereas it is permitted with prvalue. If you have a source to source
> compiler you will have to take that into account to not break code, and
> you will have to only generate std::move when the expression would be an
> lvalue.
Yeah I can do that as well, and it would convey with the C++ standards
better.
>
> Here's an example of a non-copiable non-movable type passed in parameter
> by value:
>
> void do_thing_with_mutex(std::mutex);
>
> do_thing_with_mutex(std::mutex{});
>
> If you call std::move on that prvalue, the code will be ill-formed since
> the compiler would be forced to call the move constructor.
Thanks for the head's up.
> It may look like details, but those are important details because you
> might accidentally propose things that will break people and hinder
> performance.
>
> Em sáb., 7 de jan. de 2023 16:44, Phil Bouchard via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> escreveu:
>
>
>
> On 1/7/23 03:35, Peter Olsson via Std-Proposals wrote:
> >> a.foo(move(list<int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
> >
> >> foo(move(ostream()));
> >
> > Do you realize that using std::move on a temporary like this is
> pretty
> > pointless because it's already an rvalue?
>
> I was referring to the automatic generated code by the source-to-source
> compiler. Whether it's a r-value and l-value, a move() will be
> generated.
>
>
> --
> Logo <https://www.fornux.com/ <https://www.fornux.com/>>
> *Phil Bouchard* facebook icon
> <https://www.linkedin.com/in/phil-bouchard-5723a910/
> <https://www.linkedin.com/in/phil-bouchard-5723a910/>>
> CTO
> T: (819) 328-4743
> E: phil_at_[hidden] <mailto:phil_at_[hidden]>| www.fornux.com
> <http://www.fornux.com> <http://www.fornux.com <http://www.fornux.com>>
> 8 rue de la Baie| Gatineau (Qc), J8T 3H3 Canada
>
> Banner <https://goglobalawards.org/ <https://goglobalawards.org/>>
> Le message ci-dessus, ainsi que les
> documents l'accompagnant, sont destinés uniquement aux personnes
> identifiées et peuvent contenir des informations privilégiées,
> confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce
> message par erreur, veuillez le détruire.
> This communication (and/or the attachments) is intended for named
> recipients only and may contain privileged or confidential information
> which is not to be disclosed. If you received this communication by
> mistake please destroy all copies.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden] <mailto:Std-Proposals_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
>
>
-- Logo <https://www.fornux.com/> *Phil Bouchard* facebook icon <https://www.linkedin.com/in/phil-bouchard-5723a910/> CTO T: (819) 328-4743 E: phil_at_[hidden]| www.fornux.com <http://www.fornux.com> 8 rue de la Baie| Gatineau (Qc), J8T 3H3 Canada Banner <https://goglobalawards.org/> Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés uniquement aux personnes identifiées et peuvent contenir des informations privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce message par erreur, veuillez le détruire. This communication (and/or the attachments) is intended for named recipients only and may contain privileged or confidential information which is not to be disclosed. If you received this communication by mistake please destroy all copies.
Received on 2023-01-08 18:45:58