据我所知,在C++11中,char16_t
和char32_t
不是typedefs,而是新的原始数据类型。(如果我有误,请纠正我)。
我正在编写一个库,旨在用于linux gcc和Windows Visual Studio。因此,我编写了一个特性:
template <class T>
struct IsChar : std::false_type {
};
template <>
struct IsChar<char> : std::true_type {
};
template <>
struct IsChar<wchar_t> : std::true_type {
};
template <>
struct IsChar<char16_t> : std::true_type {
};
template <>
struct IsChar<char32_t> : std::true_type {
};
然而,我注意到在VS(2013)中,char16_t
和char32_t
只是[..]\Microsoft Visual Studio 12.0\VC\include\yvals.h
中的unsigned short
和unsigned
的typedefs。
所以我进行了检查,
std::is_same<char32_t,unsigned>::value
在VS中为true
,在gcc中为false
。
所以我的问题是:
char16_t
和char32_t
是标准中的新原始类型吗?(VS实现这两个类型是否非标准?)- 这两种类型是gcc中的新原始类型,还是只是另一种typedefs(但可能与VS中的不同的typedefs)?
- VS是否计划在不久的将来将这些类型作为新的原始类型实现?
char16_t
和char32_t
是不同的类型,而且signed char
和unsigned char
也与char
不同。http://coliru.stacked-crooked.com/a/0851febbf71772dd - Praetorianchar16_t
和char32_t
类型。在它支持之前,我们在库中使用typedefs。 - James McNellis