我需要一些类型特征:
template<typename T> struct foo {};
template<>
struct foo<char> { static constexpr char c = 'c' };
Run Code Online (Sandbox Code Playgroud)
如果我需要c该类型的字符,这可以完美地工作char,但在以下情况下不是这样:
printf("%c", foo<const char>::c);
Run Code Online (Sandbox Code Playgroud)
有没有更优雅的方式来做到这一点,而不是指定两个模板char,并const char以同样的方式?