可能重複: Absence of typeof operator in C++03? 是否有可能使用模板來獲得編譯時型便攜在表達前期的C++ 0x C++?但是由於我們使用模板的,可能顯然需要 int foo() { return 0; } //Let's say we have this
typeof(foo()) x; //x would now be of type 'int'
語法
我在尋找一個相對通用的: 嘗試編譯這行代碼 如果成功,編譯和使用該行的代碼。否則 使用的代碼一些其他線路 我有,我想選擇編譯根據所提供的仿函數是否有效的東西上double秒的情況下: //Some user supplied functor I can't modify which works on `int` but not `double`
template<typename T>
str