I tried to overload the template class with SFINAE based on what type of template template had the type typedefined in it (e.g. std::remove_referencehas a member type alias type), but I can't figure out a good way to do this.
type
std::remove_reference
For example, I wanted to do
template <template <typename...> class Trait> using EnableIfHasTypeMember = std::void_t<Trait::type>; template <template <typename...> class Trait, typename OtherStuff, EnableIfHasTypeMember<Trait>* = nullptr> class Something { ... }
But this gives me a compiler error. Is there a way in which I can check the template template interface?
, , , . , , , . :
template <typename T> struct my_trait { using type = int; }; template <> struct my_trait<double> {};
, EnableIfHasTypeMember ? , .
EnableIfHasTypeMember
, my_trait<T> T . ; , , , , .
my_trait<T>
T
@Jason R , .
type, , .
// primary template handles types that have no nested ::type member: template< class, class = std::void_t<> > struct has_type_member : std::false_type { }; // specialization recognizes types that do have a nested ::type member: template< class T > struct has_type_member<T, std::void_t<typename T::type>> : std::true_type { }; // specialization recognizes class templates that do have a nested ::type member: template< template< class ... > class T, class ... Args > struct has_type_member<T<Args...>, std::void_t<typename T<Args...>::type>> : std::true_type { };
Source: https://habr.com/ru/post/1672377/More articles:How to take a screenshot using python3 and selenium - python-3.xjavascript - check for an object - jsonЗахват по значению в рекурсивной лямбда - c++Unable to complete a simple hive request: select * from pdf_table - hiveF # Equivalent to ++ operator - f #How to reset to bring down the list by default when there is nothing in the text box? - jquerywhere AWS CLI is installed during Team Services Visual Studio build - pythonIs it possible to install AWS CLI using Python2.7? - windowsWebElement # getScreenShotAs (OutputType.File) not working - javaInverted OrderedDict TypeError - pythonAll Articles