This question already has an answer here:
If I want to forward a forwarding reference perfectly, I can use std::forward
as shown in the code below:
template <typename T>
void foo(T &&x) {
bar(std::forward<T>(x));
}
Assume I can safely call foo
with an expression e
. Can I instead forward this expression directly using bar(std::forward<decltype(e)>(e))
? I understand this has limited practical appeal, but is the value category duly preserved by this decltype
approach?
Aucun commentaire:
Enregistrer un commentaire