I have some question about understanding reference collapse, so I do experiments in the following code:
template<typename T>
void func(T&& t) {}
int main() {
// There is no reference collapse here, only binding left or right values to
// references with universal reference:
int a = 10;
func(a); // this equals func<int>(a)
func(10); // what does this equal to?
func(std::move(a)); // what does this equal to?
// The following is not case of universal reference, they are reference
// collapse, only that the type is template type:
int& b1 = a;
int&& b2 = 10;
// this is the collapse of & + && -> &
func(b1); // this equals func<int&>(b1)
// this is the collapse of & + && -> &, since b2 is left reference here not
// right reference:
func(b2); // this equals func<int&&>(b2)
}
Am I correct on understanding the above code? Would you please show me the case of collapsing && + && -> &&
?