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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -