Re: basic_string ctor




"Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom> wrote in message
news:eTm0xOHXFHA.3840@xxxxxxxxxxxxxxxxxxxxxxx

> As shown in answer to Duane, you can make a valid pointer to an empty
string
> and a NULL pointer both construct a std::string as empty.
>
> But if you fold this distinction in std::string's constructor, so NULL
will
> silently construct an empty std::string, then in the situation where the
> pointer being NULL is an error in the program, this will silently pass
over
> this.

The thing is that if I want to write something that takes a null
pointer as an error, I'll check it before calling the function. More
than likely I'm converting something from a GUI layer to a standard
layer. We keep the GUI stuff separate from other code. In our case,
I can't actually think of an instance when a null char* would be treated
as anything but an empty string.

I see what you're saying but I think that in most cases, I don't agree.

Of course if I could write a function with explicit arg lists, this would
be less of a problem (g).

.



Relevant Pages

  • Re: How to sneak around a NULL value
    ... An empty string is normally a pointer to an empty BSTR (i.e. the piece of ... memory representing strings in Unicode). ... It is different in that it is actually an empty pointer rather than ...
    (microsoft.public.vb.general.discussion)
  • Re: Converting enums to pointers
    ... > You declare EMPTY to be a null pointer here. ... though it might be nice to use the extern keyword. ...
    (comp.lang.cpp)
  • Re: Trying to mimic perl with declarations
    ... Hmm...your code really only even compiles more or less accidentally ... std::string has a ctor that takes a C-style string (i.e. pointer to ... in for that pointer, so this compiles, but for the code to work, the ... references to const strings, and then I'd create a unique, empty ...
    (alt.comp.lang.learn.c-cpp)
  • Mouse Pointer Becomes 4-Way Arrow and Wont Revert
    ... In WinXP Home SP1, my mouse pointer occasionally becomes a 4-way arrow and ... will not revert to a regular pointer unless I go to the mouse properties ... PCI 1: Empty ... Firewall: Kerio Personal Firewall 2.1.4 ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Writing bulletproof code
    ... "Arthur J. O'Dwyer" wrote: ... I not only have to check that the string is ... > 1) not empty ... > 3) not a null pointer ...
    (comp.programming)