What is the return type of sizeof operator? cppreference.com & msdn says sizeof returns size_t. Does it really return a size_t? I\'m using VS2010 Professional, and targ
C++11, §5.3.3 ¶6
The result of
sizeofandsizeof...is a constant of typestd::size_t. [ Note: std::size_t is defined in the standard header (18.2). — end note ]
You can also do a quick check:
#include
#include
#include
int main()
{
std::cout<<(typeid(sizeof(int))==typeid(std::size_t))<
which correctly outputs 1 on my machine.
As @Adam D. Ruppe said in the comment, probably the compiler does not complain because, since it already knows the result, it knows that such "conversion" is not dangerous