All this originated from me poking at a compiler warning message (C4267) when attempting the following line:
const unsigned int nSize = m_vecSomeVec.size();
size() returns a size_t which although typedef’d to unsigned int, is not actually a unsigned int. This I believe have to do with 64 bit portability issues, however can someone explain it a bit better for me? ( I don’t just want to disable 64bit warnings.)
It depends on the implementation.
std::size_tfor example has a minimal required size. But there is no upper limit. To avoid these kind of situations, always use the proper typedef:You will be always on the safe side then.