max_size() vs capacity in vector help confusion
i think max_size() give max number of element any vector can store & it will be constant for any vector. and capacity max number of element that depend upon numbeer of input or push_back operation.IN below code if i replace 100 by max_size()->4611686018427387903 then why it can't able to store the value since it has max_size(),and what is the use of max_size() if it is wrong // comparing size, capacity and max_size #include <iostream> #include <vector> int main () { std::vector<int> myvector; // set some content in the vector: for (int i=0; i<100; i++) myvector.push_back(i); std::cout << "size: " << myvector.size() << "\n"; std::cout << "capacity: " << myvector.capacity() << "\n"; std::cout << "max_size: " << myvector.max_size() << "\n"; return 0; }