Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #87889
| From | Bo Persson <bo@bo-persson.se> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: R-value references and std::forward |
| Date | 2022-12-14 10:26 +0100 |
| Message-ID | <jvtj6mFq5jfU1@mid.individual.net> (permalink) |
| References | <6d19a662-76a1-4925-bd07-b259836f062bn@googlegroups.com> |
On 2022-12-14 at 09:44, Frederick Virchanza Gotham wrote: > The following code up on GodBolt: > > https://godbolt.org/z/bfs3qn5Gx > > prints out: > > Dog takes l-value ref > Monkey takes r-value ref > Hello > > I expected it to say "Monkey takes l-value ref". > > Is the behaviour undefined because of my use of 'forward' on Line #22? Should 'forward' only be used with a so-called 'template parameter forwarding reference'? > You are using it wrong, anyway. When the value is an int&, you should "forward" is using forward<int&>(arg). That's what happens with a forwarding reference.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
R-value references and std::forward Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-12-14 00:44 -0800
Re: R-value references and std::forward Bo Persson <bo@bo-persson.se> - 2022-12-14 10:26 +0100
Re: R-value references and std::forward Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-12-14 01:48 -0800
Re: R-value references and std::forward Bo Persson <bo@bo-persson.se> - 2022-12-14 12:42 +0100
Re: R-value references and std::forward Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-12-14 06:46 -0800
Re: R-value references and std::forward Öö Tiib <ootiib@hot.ee> - 2022-12-15 05:48 -0800
Re: R-value references and std::forward Juha Nieminen <nospam@thanks.invalid> - 2022-12-14 12:41 +0000
Re: R-value references and std::forward Bonita Montero <Bonita.Montero@gmail.com> - 2022-12-15 19:03 +0100
Re: R-value references and std::forward Bonita Montero <Bonita.Montero@gmail.com> - 2022-12-15 16:39 +0100
Re: R-value references and std::forward Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-12-17 10:55 -0800
csiph-web