I want to study the constructor for string to see whether for an empty string it has some default storage allocated or not (for self technical interest only), and string is defined based on basic_string<char>, so I begin to study basic_string.
But in file string, there is no constructor for basic_string. Anything wrong? Where is it?
I am using Visual Studio 2008.
thanks in advance,
The default constructor for basic_string actually accepts an argument of type Allocator (with a default value).
According to the C++ standard, the postconditions of that constructor are;
1) the data() member function returns a non-NULL pointer that is copyable and can have 0 added to it.
2) the size() member function returns zero
3) capacity() yields an unspecified value.
As to where the constructor is among VS2008's header files; I have not looked, so have no idea.
MSVC's implementation defines the string class in <xstring>. This is done to break some header dependencies.
Recent versions of GCC use <bits/basic_string.h>, or maybe even .tcc, I can't remember at the moment. I don't know why this is -- and I know it's different in GCC 2.95. (Irrelevant. Oh well.)
Also, going through header files isn't always the best way to find out whether something is so . . . it just tells you what your compiler thinks is so. :)
I have found it according to your reply.
Originally Posted by CornedBee