I understand that, given an expression initializing a forwarding/universal reference,lvalues are deduced to be of type T&
and rvalues of type T
(and not T&&
).
Thus,to allow only rvalues, one need to write
template<class T, enable_if<not_<is_lvalue_reference<T> >,OtherConds... > = yes>
void foo(T&& x) {}
and not,
template<class T, enable_if<is_rvalue_reference<T>,OtherConds... > = yes>
void foo(T&& x) {}
My question is , why for forwarding references, rvalues are deduced to be of type T
and not T&&
? I guess, if they are deduced as T&&
then also same referencing collapsing rule works as T&& &&
is same as T&&
.