|
|
Another way to request reallocation explicitly is to use the size() operation. This version, which takes a single parameter (the new size), should not be confused with the parameterless version discussed in the section ``What is array reallocation?'', which simply returns the current size. The following example uses both operations:
Block<int> b(100); ... b.size( 2*b.size() ); // size is now 200
The one-parameter size() operation returns the new size or zero in the event that reallocation failed.
Note that if the argument to size() is less than the current allocation, truncation will occur.