c++ - Type traits to match pointer to collections -



c++ - Type traits to match pointer to collections -

i writing sfinae matching class can match pointer collection type.

we have std::is_pointer , have written:

// sfinae test const_iterator fellow member type template <typename t> class has_const_iterator{ private: typedef char true; typedef long false; template <typename c> static true test(typename c::const_iterator*) ; template <typename c> static false test(...); public: enum { value = sizeof(test<t>(0)) == sizeof(char) }; };

how can utilize both std::is_pointer , has_const_iterator in std::enable_if or how can write new type traits can match pointer collection type? thanks.

template<class t> struct is_pointer_to_collection : std::integral_constant<bool, std::is_pointer<t>::value && has_const_iterator<typename std::remove_pointer<t>::type>::value> {};

demo.

c++ templates c++11 sfinae typetraits

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -