我已經習慣了的模板語法完全專用模板:使用的參數模板<>
template<typename T>
struct S {};
template<>
struct S<int> {}; // Fully specialized
但我不知道,我可以用它作爲參數:
void fn(std::function<> lambda){
}
int main() {
fn([](){ std::cout << "Hello"; });
}
上面的意思是「給我一個完全專用的std ::函數作爲參數」嗎? 爲什麼不是template <> std::function
語法?
這意味着「一個std :: function'實例化,其所有參數默認」。爲什麼'std :: function'有我目前正在查找的默認參數。 – Quentin
@Quentin根據[cppreference](http://en.cppreference.com/w/cpp/utility/functional/function)它沒有。 – Walter
它編譯? http://rextester.com/WETU77257 – songyuanyao