
----- Original Message ----- From: "Vladimir Prus" <vladimir@codesourcery.com> To: <boost@lists.boost.org> Sent: Sunday, March 07, 2010 7:25 AM Subject: Re: [boost] [program_options]
vicente.botet wrote:
Hi, ----- Original Message ----- From: "Phil Richards" <news@derived-software.ltd.uk> To: <boost@lists.boost.org> Sent: Saturday, March 06, 2010 11:59 AM Subject: Re: [boost] [program_options]
Description is even simpler: it just uses the const char* argument as a parameter to a std::string constructor. Accepting a std::string const& instead of a const char* will have minimal overheads (possibly one extra temporary string creation).
But maybe I'm missing something obvious?
The fact that currently the implementation use a temporary string doesn't means that we can not change the implementation. The interface with a string const reference involves already an allocation and deallocation when you have a const char*.
What about having both overloads? const char * is the best for literals, while string cont& is the best for strings variables.
void option_description::set_name(string const&_name); void option_description::set_name(const char* _name);
As I've said already, I don't remember why this is not provided, and will have to think about it.
Apologize, I have not read the complete thread. Best, Vicente