I'm using a library with a function that has a parameter of type int
.
I need to pass the size of the vector as the argument for this parameter.
I know I can get the the size of a vector using someVector.size()
, but this returns the type size_t
.
I know I can cast the size_t
to an int
: e.g. static_cast<int>(someVector.size())
. However, casting might cause problems if someVector.size()
exceeds the max value of int
.
What's the proper way to pass the size of a vector to a function requiring a parameter of type int
?