Yes, in C ++ 11, SFINAE has been expanded to expressions, so you can define a trait such as is_t_extension to detect the presence of member functions, for example:
template<class... T> struct holder { typedef void type; }; template<class T, class=void> struct is_t_extension : std::false_type {}; template<class T, class=void> struct is_t_extension<T, typename holder< decltype(std::declval<T>().getRequestId), decltype(std::declval<T>().getDirection), decltype(std::declval<T>().getDriveWay), decltype(std::declval<T>().getCycleId) >::type> : std::true_type {};
Now it just checks their presence. With some work, you could extend the above to discover valid signatures, or you could use the Tick library to write a lot of clean characters instead:
TICK_TRAIT(is_t_extenstion) { template<class T> auto requires_(T&& x) -> TICK_VALID( returns<unsigned long>(x.getRequestId), returns<eDirection>(x.getDirection), returns<eDriveWay>(x.getDriveWay), returns<unsigned long>(x.getCycleId) ); };
Then in your class, you can simply use static_assert to report an error:
template <typename TExtension> class foo { static_assert(is_t_extension<TExtension>(), "Not a TExtension"); };
Or, if you want to enable specialization, you can use TICK_CLASS_REQUIRES :
template <typename TExtension, class=void> class foo; template <typename TExtension> class foo<TExtension, TICK_CLASS_REQUIRES(is_t_extension<TExtension>())> { ... };