Subject: Re: [boost] [program_options] Some methods take const char*, others take std::string
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-08-15 16:25:16


On Mon, Aug 15, 2011 at 9:33 PM, Gabriel Redner <gredner_at_[hidden]> wrote:
> This is all true, but it's important to keep in mind our use cases.
> In general, these APIs will be called with string literals.  The
> next-most-common case is for them to be called with std::strings, and
> other cases are even less likely.  So it seems best to do the simplest
> thing possible which covers the common cases and does not rule out the
> uncommon ones.

Using str_ref would require only a single overload, while using const
char* and const str::string& would require two. So what is the
simplest thing possible?

> Your compromise is missing one factor - simplicity.  This is a simple
> API which does a simple job.  Decorating it with generic tools will
> make it harder to understand and to maintain, in exchange for some
> small benefit in uncommon use cases.

This isn't the only lib that takes string references. It'd be nice to
solve this properly once and for all.

Olaf