SFINAE compiler troubles
问题 The following code of mine should detect whether T has begin and end methods: template <typename T> struct is_container { template <typename U, typename U::const_iterator (U::*)() const, typename U::const_iterator (U::*)() const> struct sfinae {}; template <typename U> static char test(sfinae<U, &U::begin, &U::end>*); template <typename U> static long test(...); enum { value = (1 == sizeof test<T>(0)) }; }; And here is some test code: #include <iostream> #include <vector> #include <list>