Boost logo

Boost :

Subject: [boost] [program_options] Some methods take const char*, others take std::string
From: Gabriel Redner (gredner_at_[hidden])
Date: 2011-08-10 15:01:59


Hi all,

Some methods in program_options accept const char*s (e.g.
option_description constructor), while others take const std::string&s
(e.g. option_description::key). This makes no difference to the user
if he is passing string literals, but becomes annoying if he wants to
pass strings, or expressions which return strings. Of course he can
put (...).c_str() everywhere, but this is ugly and unnecessary, since
program_options just takes its parameters and shoves them into string
variables anyways. Since changing the parameter types to const
std::string& should not break existing code, I do not see a downside
to doing so (plus, it would allow me to get rid of .c_str()s
everywhere :-).

Does it seem reasonable for program_options public APIs to accept
std::strings instead of const char*s? If so I would be happy to do
the legwork and submit a patch.

Thanks,
-Gabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk