[Assorted-commits] SF.net SVN: assorted: [434] sandbox/trunk/src/cc/allocator_max_size.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-15 02:34:40
|
Revision: 434 http://assorted.svn.sourceforge.net/assorted/?rev=434&view=rev Author: yangzhang Date: 2008-02-14 18:34:45 -0800 (Thu, 14 Feb 2008) Log Message: ----------- added test for allocator::max_size Added Paths: ----------- sandbox/trunk/src/cc/allocator_max_size.cc Added: sandbox/trunk/src/cc/allocator_max_size.cc =================================================================== --- sandbox/trunk/src/cc/allocator_max_size.cc (rev 0) +++ sandbox/trunk/src/cc/allocator_max_size.cc 2008-02-15 02:34:45 UTC (rev 434) @@ -0,0 +1,36 @@ +// +// These printouts basically show that max_size is meaningless in the default +// allocators - it's just the size of memory / sizeof(type). +// + +#include <iostream> +#include <vector> +using namespace std; + +int main() +{ + vector<short int>::allocator_type vectorShortIntAllocator; + vector<int>::allocator_type vectorIntAllocator; + vector<long int>::allocator_type vectorLongAllocator; + vector<float>::allocator_type vectorFloatAllocator; + vector<double>::allocator_type vectorDoubleAllocator; + + cout << "Here are the number of object that can be allocated.\n"; + cout << "short integers: "; + cout << vectorShortIntAllocator.max_size() << endl; + + cout << "integers: "; + cout << vectorIntAllocator.max_size() << endl; + + cout << "long integers: "; + cout << vectorLongAllocator.max_size() << endl; + + cout << "floats: "; + cout << vectorFloatAllocator.max_size() << endl; + + cout << "doubles: "; + cout << vectorDoubleAllocator.max_size() << endl; + + return 0; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |