$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] RFC: interest in Unicode codecs?
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-07-21 09:41:02
Phil Endecott wrote:
> Is c_str() allowed to be > O(1) ?
Yes. In particular, this implementation is valid:
template <...>
class basic_string
{
Ch *real_data;
mutable Ch *cstr_data;
// ...
public:
const Ch *c_str() const {
if (!cstr_data) {
cstr_data = allocate(size() + 1);
copy(cstr_data, size());
cstr_data[size()] = 0;
}
return cstr_data;
}
void any_modifying_function() {
if(cstr_data) {
deallocate(cstr_data);
cstr_data = 0;
}
}
};
Sebastian