enable_if iterator as a default template parameter?
问题 I have a constructor like that : class MyClass { template<class TI> MyClass(TI first, TI last); }; template<class TI> MyClass::MyClass(TI first, TI last) { ; } I would like to enable this constructor only if TI is an iterator (that means TI has an iterator_category I think). How to do that in C++ 2011 using an enable_if as a default template parameter (in the declaration and in the definition) ? Thank you very much. 回答1: It depends on what you want. If there are no other overloads, it can be