Boost logo

Boost :

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-20 10:01:56


On Mon, Aug 15, 2011 at 10:25 PM, Olaf van der Spek <ml_at_[hidden]> wrote:
> 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?

Not using str_ref would require a third overload: (const char*,
size_t). Even then, it still doesn't support for example vector<char>,
CString (MFC) or QString (QT).

Olaf


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