Importance of Universal Reference in C++

209 Views Asked by At

I started reading books and blog posts by Scott Meyers to improve my C++ skills. I read the blog about Universal References in C++, and I'm trying to understand it.

Is the reason for the existence of this term as a concept because of std::forward, or is there something else to give more attention?

As far as I understood, a deduced type with &&, called a universal reference, does not always mean an rvalue reference, but sometimes means an lvalue reference. We need to be careful if we need to preserve rvalueness of a function argument, because all the function parameters are lvalues even though they are rvalue reference types. std::forward is a solution with these universal references.

Is there something else I am missing?

Meyers dedicated a whole section to this in one of his books, and he wrote some blogs about it, so I'm concerned if I am not able to see the importance of this topic.

Could you help me with that, please?

0

There are 0 best solutions below