Skip to content

Instantly share code, notes, and snippets.

@LucianoPAlmeida
Last active December 3, 2021 22:49
Show Gist options
  • Save LucianoPAlmeida/8a11e1b35814889d41c9d5d853703a4f to your computer and use it in GitHub Desktop.
Save LucianoPAlmeida/8a11e1b35814889d41c9d5d853703a4f to your computer and use it in GitHub Desktop.
template<typename T>
void f(T&& param);
// T is deduced so && means universal reference
void f(std::string&& param);
// No deduction involved so && means r-value reference
template<typename T>
void a(T&& param) { /*does something*/ }
template<typename T>
void b(T&& param) {
// Since both are UR forward preserve valueness function
// `a` will receive a l or r value depending on the param
// passed to `b`.
a(std::forward<T>(param));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment