On 09/07/2011 11:11 AM, Julien Rioux wrote:
On 07/09/2011 5:06 PM, Richard Heck wrote:
I push an empty string to prevent extension_list_ from being empty,
because in Format.h we have
- std::string const & extension() const { return extension_; }
+ std::string const & extension() const { return extension_list_[0]; }
and extension_list_[0] would be an invalid address otherwise.
return extension_list_.empty() ? "" : extension_list_[0]?
rh
I tried exactly this and it throws a bunch of warnings: returning
reference to temporary. That's when I went for the approach in the patch.
Oh, I see, we're returning a reference. In that case:
return extension_list_.empty() ? empty_string() : extension_list_[0];
The empty_string() and empty_docstring() functions are defined in
lstrings.h.
It doesn't matter a lot, obviously, but it's natural to worry someone
might someday modify extension_list_ and forget to make sure it isn't
empty. Like me.
Richard