public member function


allocator_type get_allocator() const;
allocator_type get_allocator() const noexcept;
Get allocator
Returns a copy of the allocator object associated with the string.

string uses the default allocator<char> type, which has no state (thus, the value returned is the same as a default-constructed allocator).



Return Value

An allocator object.

In string, member type allocator_type is an alias of allocator<char>.


Unspecified, but generally constant.

Iterator validity

No changes.

Data races

The object is accessed.

Exception safety

No-throw guarantee: this member function never throws exceptions.
Copying any instantiation of the default allocator is also guaranteed to never throw.

See also