天天看點

template --- decay

對于非引用類型的參數,在實參演繹的過程中會出現從數組到指針(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:

template --- decay

繼續閱讀