Topic: How to construct a basic_string<char> from a char?


Author: mlg@scr.siemens.com (Michael Greenberg)
Date: 1995/05/08
Raw View
I don't know if I'm missing something, or if there's a problem with
the draft standard...

In several places, the description of basic_string uses a constructor
of the form basic_string(charT). But I've been unable to find
such a constructor in the document.  There is also reference to a
constructor of the form basic_string<charT>(charT, size_type).

Am I missing something?


Perhaps the constructor of the form

  basic_string(size_type n, charT c, Allocator& = Allocator())

is supposed to read

  basic_string(charT c, size_type n=1, Allocator& = Allocator())


Assuming my guess is correct, is it also the case that

  append(size_type n, charT)

also has arguments reversed?




Thanks,


--
Michael Greenberg                      email: mgreenberg@scr.siemens.com
Siemens Corporate Research             phone: 609-734-3347
755 College Road East                  fax: 609-734-6565
Princeton, NJ 08540





Author: jason@cygnus.com (Jason Merrill)
Date: 1995/05/08
Raw View
>>>>> Michael Greenberg <mlg@scr.siemens.com> writes:

> I don't know if I'm missing something, or if there's a problem with
> the draft standard...

> In several places, the description of basic_string uses a constructor
> of the form basic_string(charT). But I've been unable to find
> such a constructor in the document.  There is also reference to a
> constructor of the form basic_string<charT>(charT, size_type).

Those references are mistakes in the draft.

> Perhaps the constructor of the form

>   basic_string(size_type n, charT c, Allocator& = Allocator())

> is supposed to read

>   basic_string(charT c, size_type n=1, Allocator& = Allocator())

It used to read like that, but was changed for STL compatibility.

Jason