why can not get sizeof of a list? Is it like Type *array; that you can not get the size of array and just return the size of pointer which point ro first element of array?
sizeof return 16 for both sizeof(C1/2)=16 and sizeof(char)=1 ,sizeof(char)=8.why sizeof for any list type return 16byte?
inorder to get size of a list i should multiply list.size by sizeof(list type)???
std::list probably contains two pointers, one to the first node and one to the last node. If the size of a pointer is 8 bytes that adds up to 16 bytes. In C++11 it would also have to keep track of the number of elements so if you compile the code in C++11 it would probably give you a size of 24 bytes.
Peter87, on 32-bits, the size of a pointer is 4 bytes. Being there 4 pointers (suppose a pointer-sized _M_data variable) the size of the struct is 16 byte, because you are getting the list's size, not the content's size.
It is hard to read through the source code of the STL because you're not supposed to do it. The problem here is that the OP is seeing implementation-defined behavior.
There's nothing wrong looking at the C++ library headers (or even sources), just keep in mind that every implementation is different. Personally, I like LLVM libc++ code best: http://llvm.org/svn/llvm-project/libcxx/trunk/include/list