Boost logo

Boost :

Subject: Re: [boost] Request for Interest in several Modules
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2012-01-11 07:44:38


Klaim - Joël Lamotte wrote:
> On Wed, Jan 11, 2012 at 10:30, Artyom Beilis <artyomtnk_at_[hidden]>
> wrote:
>
> > Why not? std::string is convertable from char const * also
> > "creating string" price is quite negligible in comparison to
> > loading library...
>
> I agree but lot of libraries that take such inputs uses const
> char * to avoid forcing to use std::string, as some plateform
> implement it in a non efficient way (I'm thinking embedded), so
> I was asking to know if there is a particular reason. I
> personally don't mind, I also don't know if it's a important
> thing for boost, but it might be if you try to standardize it
> one day I guess.

The cost of creating a std::string may be relatively negligible, but that doesn't make it zero. Don't forget that it puts additional pressure on the free store. If a std::string is not needed, don't create one.

That said, the best approach might simply be overloading. If clients have a std::string, it can bind to a std::string const & parameter, thus avoiding the need to use c_str() (in the char const *-only approach). If clients have a char const *, an overload accepting that will prevent creating a std::string unnecessarily.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com




________________________________

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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