I was playing with std::is_same utility function in combination with rvalue and lvalue reference and came across a weird behavior.
Consider this function template which checks the type of variable t.
I am using VS 2013 :
struct Test {};
template < class T> void h(T && t)
{
cout << " Is type &&: " << std::is_same<decltype(t), T &&>::value << endl;
cout << " Is type &: " << std::is_same<decltype(t), T &>::value << endl;
}
I observe the following outputs :
h(Test()); // is type && : 1 is type & : 0
which is normal for now as Test() is a temporary object, and the universal reference in parameter of h resolves to a r value reference (&& && = &&)
but consider this :
Test myTest;
h(myTest); // is type && : 1 is type & : 1 !!!
same result if i write :
Test &myTest = Test():
h(myTest); // is type && : 1 is type & : 1 !!!
and same with :
Test &&myTest = Test():
h(myTest); // is type && : 1 is type & : 1 !!!
AM I missing something ? It looks like a complete mess to me :) Are the features rvalue reference / decltype not fully supported in VS 2013?
thanks for your help
Romain
TisTest&. - T.C.h<Test&>, and soT&&isTest&. - Jarod42