c++ - Detecting basic_string instantiation -
i wrote following code determine if type instantiation of std::basic_string
:
template <typename t> struct is_string { enum { value = false }; }; template <typename chart, typename traits, typename alloc> struct is_string<std::basic_string<chart, traits, alloc> > { enum { value = true }; };
is there more succinct way achieve that?
okay, found shorter way:
#include <type_traits> template <typename t> struct is_string : std::false_type {}; template <typename chart, typename traits, typename alloc> struct is_string<std::basic_string<chart, traits, alloc> > : std::true_type {};
but maybe others can better? :)
Comments
Post a Comment