對於非引用類型的參數,在實參演繹的過程中會出現從數組到指針(array-to-pointer)的類型轉變,稱之爲退化(decay)
test.h
#include<iostream>
#include<typeinfo>
template<class T>
void ref(T& t) {
std::cout << typeid(t).name() << std::endl;
}
template<class T>
void noref(T t) {
std::cout << typeid(t).name() << std::endl;
}
main.cpp
::ref("hei");
::noref("hei");
print: