public member function
<string>
std::basic_string::basic_string default (1)explicit basic_string (const allocator_type& alloc = allocator_type());copy (2)
basic_string (const basic_string& str);substring (3)
basic_string (const basic_string& str, size_type pos, size_type len = npos, const allocator_type& alloc = allocator_type());from c-string (4)
basic_string (const charT* s, const allocator_type& alloc = allocator_type());from sequence (5)
basic_string (const charT* s, size_type n, const allocator_type& alloc = allocator_type());fill (6)
basic_string (size_type n, charT c, const allocator_type& alloc = allocator_type());range (7)
template <class InputIterator> basic_string (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());default (1)
explicit basic_string (const allocator_type& alloc = allocator_type());copy (2)
basic_string (const basic_string& str);basic_string (const basic_string& str, const allocator_type& alloc);substring (3)
basic_string (const basic_string& str, size_type pos, size_type len = npos, const allocator_type& alloc = allocator_type());from c-string (4)
basic_string (const charT* s, const allocator_type& alloc = allocator_type());from buffer (5)
basic_string (const charT* s, size_type n, const allocator_type& alloc = allocator_type());fill (6)
basic_string (size_type n, charT c, const allocator_type& alloc = allocator_type());range (7)
template <class InputIterator> basic_string (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());initializer list (8)
basic_string (initializer_list<charT> il, const allocator_type& alloc = allocator_type());move (9)
basic_string (basic_string&& str) noexcept;basic_string (basic_string&& str, const allocator_type& alloc);default (1)
basic_string();explicit basic_string (const allocator_type& alloc);copy (2)
basic_string (const basic_string& str);basic_string (const basic_string& str, const allocator_type& alloc);substring (3)
basic_string (const basic_string& str, size_type pos, size_type len = npos, const allocator_type& alloc = allocator_type());from c-string (4)
basic_string (const charT* s, const allocator_type& alloc = allocator_type());from buffer (5)
basic_string (const charT* s, size_type n, const allocator_type& alloc = allocator_type());fill (6)
basic_string (size_type n, charT c, const allocator_type& alloc = allocator_type());range (7)
template <class InputIterator> basic_string (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());initializer list (8)
basic_string (initializer_list<charT> il, const allocator_type& alloc = allocator_type());move (9)
basic_string (basic_string&& str) noexcept;basic_string (basic_string&& str, const allocator_type& alloc);
Construct basic_string object
Constructs a basic_string object, initializing its value depending on the constructor version used:The
basic_stringobject keeps an internal copy of
alloc, which is used to allocate and free storage for the characters it contains throughout its lifetime.
The copy constructor
(2)creates an object that keeps and uses a copy of
str's allocator.
The
basic_stringobject keeps an internal copy of
alloc, which is used to allocate and free storage for the characters it contains.
The copy constructor
(2, first signature)creates a container that keeps and uses a copy of the allocator returned by calling the appropriate
selected_on_container_copy_constructiontrait on
str's allocator.
The move constructor
(9, first signature)acquires
str's allocator.
The
basic_stringobject keeps an internal copy of
alloc, which is used to allocate and free storage for the characters it contains.
The default constructor
(1, first signature)uses a default-constructed allocator.
The copy constructor
(2, first signature)creates a container that keeps and uses a copy of the allocator returned by calling the appropriate
selected_on_container_copy_constructiontrait on
str's allocator.
The move constructor
(9, first signature)acquires
str's allocator.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// string constructor
#include <iostream>
#include <string>
int main ()
{
std::string s0 ("Initial string");
// constructors used in the same order as described above:
std::string s1;
std::string s2 (s0);
std::string s3 (s0, 8, 3);
std::string s4 ("A character sequence", 6);
std::string s5 ("Another character sequence");
std::string s6 (10, 'x');
std::string s7a (10, 42);
std::string s7b (s0.begin(), s0.begin()+7);
std::cout << "s1: " << s1 << "\ns2: " << s2 << "\ns3: " << s3;
std::cout << "\ns4: " << s4 << "\ns5: " << s5 << "\ns6: " << s6;
std::cout << "\ns7a: " << s7a << "\ns7b: " << s7b << '\n';
return 0;
}
s1: s2: Initial string s3: str s4: A char s5: Another character sequence s6: xxxxxxxxxx s7a: ********** s7b: Initial
Unspecified.
Unspecified, but generally linear in the resulting
string length(and constant for
move constructors).
If s is a null pointer, if n == npos, or if the range specified by [first,last) is not valid, it causes undefined behavior.
If pos is greater then str's length, an out_of_range exception is thrown.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4