Standard C++ Library Class Reference
Constructors and Destructors
In all cases, the Allocator parameter will be used for storage management.
explicit
basic_string (const Allocator& a = Allocator());
The default constructor. Creates a basic_string with the following effects:
data() a non-null pointer that is copyable and can have 0 added to it
size() 0
capacity() an unspecified value
basic_string (const basic_string<T, traits, Allocator>& str);
Copy constructor. Creates a string that is a copy of str.
basic_string (const basic_string &str, size_type pos,
size_type n= npos);
Creates a string if pos<=size() and determines length rlen of initial string value as the smaller of n and str.size() - pos.
This has the following effects:
data() points at the first element of an allocated copy of rlen elements of the string controlled by str beginning at
position pos
size() rlen
capacity() a value at least as large as size()
get_allocator() str.get_allocator()
An out_of_range exception will be thrown if pos>str.size().
basic_string (const charT* s, size_type n,
const Allocator& a = Allocator());
Creates a string that contains the first n characters of s. s must not be a NULL pointer. The effects of this constructor are:
data() points at the first element of an allocated copy of the array whose first element is pointed at by s
size() n
capacity() a value at least as large as size()
An out_of_range exception will be thrown if n == npos.
basic_string (const charT * s,
const Allocator& a = Allocator());
Constructs a string containing all characters in s up to, but not including, a traits::eos() character. s must not be a null
pointer. The effects of this constructor are:
data() points at the first element of an allocated copy of the array whose first element is pointed at by s
size() traits::length(s)
capacity() a value at least as large as size()
basic_string (size_type n, charT c,
const Allocator& a = Allocator());
Constructs a string containing n repetitions of c. A length_error exception is thrown if n == npos. The effects of this
constructor are:
data() points at the first element of an allocated array of n elements, each storing the initial value c
size() n