Re: basic_string ctor




"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx> wrote in message
news:eUe10xwWFHA.2768@xxxxxxxxxxxxxxxxxxxxxxx
> John wrote:
> > Hi,
> >
> > Is it legal C++ (by which I mean according to the standard spec) to
> > pass a null into a basic_string ctor? Or, more precisely, is it
> > legal C++ to pass a null pointer into a basic_string parameter on a
> > method?
>
> No, it's not. The committee was worried about the cost of the extra if() in
> the constructor being too high (misplaced premature optimization, IMO).

In my opinion the cost of the extra if() would have been well worth
it. One of the problems with the string.h functions was the need to
check everything (if(ptr)(if strlen(prt)) //do something with ptr)

Having functions that take std::string and give expected results
with null would have been great. I've heard from people involved
with the standard that this may be changed.


> Many C++ library implementations will in fact crash if you pass null.

Most that I've used.


.



Relevant Pages

  • Re: Absolute or just relative fitness?
    ... >> rule discriminate between altruism and mutualism? ... > John asserts that question A and question B mean ... a cost c that is ... the cost c to the donor. ...
    (sci.bio.evolution)
  • Re: project summary task, ID # 0
    ... John from NY wrote: ... 'resource' labeled 'cost' as contrasted to work or materials or fixed cost? ... there is only one Project Summary Task. ... G & A and profit be incorporated into Project's Budget ...
    (microsoft.public.project)
  • Re: I dont know if I can take much more.....
    ... Next the boat engine overheats and who knows what that will cost. ... My wife calls me downstairs at about 9:30 this morning to find our basement ... John H ... Sorry John, our new carpeting and trim comes out of our pocket, as does ...
    (rec.boats)
  • Re: Great Guy John Wart Jr
    ... has helped me out with PROMs, (at an affordable price, I might add), and ... Lets Just assume John Got nice clean Label free blank ROMS that he ... Shipping cost and expenses cancel each other out so we will disregard ... ROM burner, ROM Eraser ...
    (rec.games.pinball)
  • Re: this is getting crazy
    ... John Larkin wrote: ... Equivalent 14 pin components 0.58 sq in/14 pin component ... LEDs) is $8 less than the micro cost in the design it replaced. ... The original control board had about $45 worth of components, ...
    (sci.electronics.design)