Use the vector::size()
method: i < v.size()
.
The sizeof
operator returns the size in bytes of the object or expression at compile time, which is constant for a std::vector
.
More Related Contents:
- How to enforce move semantics when a vector grows?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Alternative to vector
- std::vector versus std::array in C++
- How to avoid memory leaks when using a vector of pointers to dynamically allocated objects in C++?
- c++ vector size. why -1 is greater than zero
- Arrays vs Vectors: Introductory Similarities and Differences [closed]
- Vectors and polymorphism in C++
- Does vector::erase() on a vector of object pointers destroy the object itself?
- Convert Mat to Array/Vector in OpenCV
- Vectors in Arduino
- Vector assignment crashing
- vector::size_type in C++
- splitting a string into an array in C++ without using vector
- Is it possible to initialize std::vector over already allocated memory?
- Initializer-list-constructing a vector of noncopyable (but movable) objects
- array vs vector vs list
- C++ N nested vectors at runtime
- How to read a file into vector in C++?
- C++ convert vector to vector
- Get the first column of a matrix represented by a vector of vectors
- Is std::vector memory freed upon a clear?
- Initializing a ublas vector from a C array
- Why is a C++ Vector called a Vector? [closed]
- How to use new std::byte type in places where old-style unsigned char is needed?
- C++ STL: Array vs Vector: Raw element accessing performance
- gdb Could not find operator[]
- Write concurrently vector
- C++ – value of uninitialized vector
- How to cheaply assign C-style array to std::vector?