Here are some strategies for handling type expansion and truncation errors.
std::vector<int> myVec; long nVecSize = (long)myVec.size(); // no warning
extern long myGetSize(const std::vector<int> & ); // applies the truncation hard cast internally std::vector<int> myVec; long nVecSize = myGetSize(myVec );
std::vector<int> myVec; // we know size is < 4G, so is okay to ignore warning #pragma warning (push) #pragma warning (disable: 4267) long nVecSize = myGetSize(myVec); #pragma warning (pop)