Topic: Container resize() takes initializer by value?
Author: stephen.webb@bregmasoft.com (Stephen M. Webb)
Date: Tue, 31 Jul 2001 19:48:50 GMT Raw View
I notice that the resize member function in the standard containers
takes its initializer by value, that is its signature is this.
void resize(size_type sz, T c = T());
I also notice that many implementations (though not all) have resize
take its initializer by const reference, ie.
void resize(size_type sz, const T c& = T());
Since passing by const reference eliminates a (potentially expensive)
copy, and since the implementation of resize in most containers is to
just call insert, which takes its initializer by const reference
anyway, this makes more sense to me.
Is there any good reason why this particular member function is
specified to take its initializer by value instead of by const
reference in the standard?
_______
Stephen M. Webb
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]