我对理解引用崩溃有一些疑问,所以我在以下代码中做了实验:
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 = …Run Code Online (Sandbox Code Playgroud)