What is std::safe_string?

c++, string

Solution

After searching google code search (I should have thought of this first...) I found this:

//tools-cgi.cpp
string safe_string (const char * s)
{
    return (s != NULL) ? s : "";
}

Which converts `NULL`s to zero length strings. Although this is not standard it's probably some sort of extension in a specific STL implementation which was referred to in the answer.

Problem

An answer to one of my questions included the following line of code: ``` label = std::safe_string(name); // label is a std::string ``` The intent seems to be a wrapper around a string literal (so presumably no allocation takes place). I've never heard of `safe_string` and neither, apparently, has google (nor could I find it in the 98 standard). Does anyone know what this is about?

Original source

Related problems