我在看下面的模板功能,並想知道幕後發生的事情,當我們分配enable_if
型到typename
關鍵字:分配一個類型到typename關鍵字
template <typename T, typename = std::enable_if<std::is_pointer<T>::value>::type>
// ^^ What happens here?
void foo()
{
std::cout << "T is a pointer!" << std::endl;
}
其他則明顯SFINAE,編譯器是否真的用它做了什麼?也許它會產生某種匿名類型?
感謝
這是一個默認參數[未命名的模板參數](http://stackoverflow.com/questions/6718094/anonymous-template-typename-class-declarations)。 – LogicStuff