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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -