Size of float array declared is suing auto is different than actual size. why is it so ??
For e.g:
declaration:
float duto[] = {2.2222f,2.223f,34.5f,1.0f,9.0f};
auto dutot = {2.2222f,2.223f,34.5f,1.0f,9.0f};
Size print:
std::cout << " float array size v: " << sizeof(duto)<<std::endl;
std::cout << " auto v: " << sizeof(dutot)<<std::endl;
Output:
float array size v: 20
auto v: 16
auto dutot = {2.2222f,2.223f,34.5f,1.0f,9.0f};
auto
here is actually deduced as initializer_list<float>
. so you are printing the size of initializer_list<float>
.
I just took a look at initializer_list
implementation in g++ 4.8.2 on my ubuntu 14.04. it contains two members _M_array
and _M_len
. _M_array
is a pointer, _M_len
's type is size_t. So I guess your machine is 64bit. since pointer and size_t are usually 8 bytes on 64bit platform.