Scott Meyers says (for parameters to function templates):
Universal references can only occur in the form "
T&&
"! Even the simple addition of aconst
qualifier is enough to disable the interpretation of "&&
" as a universal reference.
Why doesn't C++ have a const
universal reference? Any technical reason?
What would a const universal reference be? It would be a reference that can not be modified. And moving from an rvalue-reference is a modification. Therefore, if there is such a thing as a const universal reference, it is simply const T&
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With