[Assorted-commits] SF.net SVN: assorted: [390] cpp-commons/trunk/src/commons/region.h
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-12 16:45:06
|
Revision: 390 http://assorted.svn.sourceforge.net/assorted/?rev=390&view=rev Author: yangzhang Date: 2008-02-12 08:45:07 -0800 (Tue, 12 Feb 2008) Log Message: ----------- implemented max_size Modified Paths: -------------- cpp-commons/trunk/src/commons/region.h Modified: cpp-commons/trunk/src/commons/region.h =================================================================== --- cpp-commons/trunk/src/commons/region.h 2008-02-12 16:35:02 UTC (rev 389) +++ cpp-commons/trunk/src/commons/region.h 2008-02-12 16:45:07 UTC (rev 390) @@ -8,6 +8,8 @@ namespace commons { + using namespace std; + /** * Default chunk size is 100MB. */ @@ -121,10 +123,13 @@ ~region_alloc() throw() { region->decref(); } /** - * Return maximum number of elements that can be allocated. Throws an - * exception. + * Return maximum number of elements that can be allocated. Simply return + * the size based on the size of memory. */ - size_type max_size() const throw() { throw exception(); } + size_type max_size() const throw() + { + return numeric_limits<size_t>::max() / sizeof(T); + } /** * Allocate (but don't initialize) num elements of type T. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |