Reputation: 799
I recently learned that using size_t
as opposed to std::size_t
in C++ is non-standard, and had to change my code because of it. I've read in some other answers that char16_t
and char32_t
are also introduced as typedefs, however intellisense only recognizes them without std::
, and I don't know which header they come from, except the C header <uchar.h>
, according to cppreference.com.
Should I prefix std::
for these types? And if so, which C++ header are they defined in?
Upvotes: 2
Views: 164
Reputation: 597860
In C++11 and later, char16_t
and char32_t
are built-in types of the C++ language itself, like char
and wchar_t
are. They are not part of the standard library, so no, they are not in the std::
namespace, or defined in any header file.
Upvotes: 2
Reputation: 474186
I've read in some other answers that char16_t and char32_t are also introduced as typedefs
Either these answers are wrong or you are misunderstanding what you read (or they were talking about C).
char16_t
and char32_t
are keywords in C++ (unlike size_t
). They are fundamental types, just like int
and float
. They are types distinct from all other types, but they do have an underlying type (std::uint_least16_t
and std::uint_least32_t
respectively).
In C11, char16_t
and char32_t
are typedefs defined in the header <uchar.h>
. Maybe the answer was talking about C.
Upvotes: 2