Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,120 questions

11,301 answers

573 users

How to get vector max size by type in C++

1 Answer

0 votes
#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;

int main()
{
	vector<short int>::allocator_type vecShortInt;
	vector<int>::allocator_type vecInt;
	vector<long int>::allocator_type  vecLongInt;
	vector<float>::allocator_type vecFloat;
	vector<double>::allocator_type vecDouble;

	cout << "short int: " << vecShortInt.max_size() << endl;

	cout << "int: " << vecInt.max_size() << endl;

	cout << "long int: " <<	vecLongInt.max_size() << endl;

	cout << "float: " << vecFloat.max_size() << endl;

	cout << "double: " << vecDouble.max_size() << endl;

	return 0;
}


/*
run:

short int: 2147483647
int: 1073741823
long int: 1073741823
float: 1073741823
double: 536870911

*/



answered May 17 by avibootz
...