Standard Template Library Programmer's Guide

Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

This document contains reference on SGI STL implementation

Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Example

int main() {

string s(10u, ' '); // Create a string of ten blanks.

const char* A = "this is a test";

s += A;

cout << "s = " << (s + '\n');

cout << "As a null-terminated sequence: " << s.c_str() << endl;

cout << "The sixteenth character is " << s[15] << endl;

reverse(s.begin(), s.end());

s.push_back('\n');

cout << s;

}

Definition

Defined in the standard header string.

Template parameters
Parameter Description Default
charT The string's value type: the type of character it contains.
traits The Character Traits type, which encapsulates basic character operations. char_traits
Alloc The string's allocator, used for internal memory management. alloc
Model of

Random Access Container, Sequence.

Type requirements

In addition to the type requirements imposed by Random Access Container and Sequence:

• charT is a POD ("plain ol' data") type.

• traits is a Character Traits type whose value type is charT

Public base classes

None.

Members
Member Where defined Description
value_type Container The type of object, CharT , stored in the string.
pointer Container Pointer to CharT .
reference Container Reference to CharT
const_reference Container Const reference to CharT
size_type Container An unsigned integral type.
difference_type Container A signed integral type.
static const size_type npos basic_string The largest possible value of type size_type . That is, size_type(-1) .
iterator Container Iterator used to iterate through a string. A basic_string supplies Random Access Iterators.
const_iterator Container Const iterator used to iterate through a string.
reverse_iterator Reversible Container Iterator used to iterate backwards through a string.
const_reverse_iterator Reversible Container Const iterator used to iterate backwards through a string.
iterator begin() Container Returns an iterator pointing to the beginning of the string.
iterator end() Container Returns an iterator pointing to the end of the string.
const_iterator begin() const Container Returns a const_iterator pointing to the beginning of the string.
const_iterator end() const Container Returns a const_iterator pointing to the end of the string.
reverse_iterator rbegin() Reversible Container Returns a reverse_iterator pointing to the beginning of the reversed string.
reverse_iterator rend() Reversible Container Returns a reverse_iterator pointing to the end of the reversed string.
const_reverse_iterator rbegin() const Reversible Container Returns a const_reverse_iterator pointing to the beginning of the reversed string.
const_reverse_iterator rend() const Reversible Container Returns a const_reverse_iterator pointing to the end of the reversed string.
size_type size() const Container Returns the size of the string.
size_type length() const basic_string Synonym for size() .
size_type max_size() const Container Returns the largest possible size of the string.
size_type capacity() const basic_string See below.
bool empty() const Container true if the string's size is 0 .
reference operator[](size_type n) Random Access Container Returns the n 'th character.
const_reference operator[](size_type n) const Random Access Container Returns the n 'th character.
const charT* c_str() const basic_string Returns a pointer to a null-terminated array of characters representing the string's contents.
const charT* data() const basic_string Returns a pointer to an array of characters (not necessarily null-terminated) representing the string's contents.
basic_string() Container Creates an empty string.
basic_string(const basic_string& s, size_type pos = 0, size_type n = npos) Container, basic_string Generalization of the copy constructor.
basic_string(const charT*) basic_string Construct a string from a null-terminated character array.
basic_string(const charT* s, size_type n) basic_string Construct a string from a character array and a length.
basic_string(size_type n, charT c) Sequence Create a string with n copies of c .
template basic_string(InputIterator first, InputIterator last) Sequence Create a string from a range.
~basic_string() Container The destructor.
basic_string& operator=(const basic_string&) Container The assignment operator
basic_string& operator=(const charT* s) basic_string Assign a null-terminated character array to a string.
basic_string& operator=(charT c) basic_string Assign a single character to a string.
void reserve(size_t) basic_string See below.
void swap(basic_string&) Container Swaps the contents of two strings.
iterator insert(iterator pos, const T& x) Sequence Inserts x before pos .
template void insert(iterator pos, InputIterator f, InputIterator l)[1] Sequence Inserts the range [first, last) before pos .
void insert(iterator pos, size_type n, const T& x) Sequence Inserts n copies of x before pos .
basic_string& insert(size_type pos, const basic_string& s) basic_string Inserts s before pos .
basic_string& insert(size_type pos, const basic_string& s, size_type pos1, size_type n) basic_string Inserts a substring of s before pos .
basic_string& insert(size_type pos, const charT* s) basic_string Inserts s before pos .
basic_string& insert(size_type pos, const charT* s, size_type n) basic_string Inserts the first n characters of s before pos .
basic_string& insert(size_type pos, size_type n, charT c) basic_string Inserts n copies of c before pos .
basic_string& append(const basic_string& s) basic_string Append s to *this .
basic_string& append(const basic_string& s, size_type pos, size_type n) basic_string Append a substring of s to *this .
basic_string& append(const charT* s) basic_string Append s to *this .
basic_string& append(const charT* s, size_type n) basic_string Append the first n characters of s to *this .
basic_string& append(size_type n, charT c) basic_string Append n copies of c to *this .
template basic_string& append(InputIterator first, InputIterator last) basic_string Append a range to *this .
void push_back(charT c) basic_string Append a single character to *this .
basic_string& operator+=(const basic_string& s) basic_string Equivalent to append(s) .
basic_string& operator+=(const charT* s) basic_string Equivalent to append(s)
basic_string& operator+=(charT c) basic_string Equivalent to push_back(c)
iterator erase(iterator p) Sequence Erases the character at position p
iterator erase(iterator first, iterator last) Sequence Erases the range [first, last)
basic_string& erase(size_type pos = 0, size_type n = npos) basic_string Erases a range.
void clear() Sequence Erases the entire container.
void resize(size_type n, charT c = charT()) Sequence Appends characters, or erases characters from the end, as necessary to make the string's length exactly n characters.
basic_string& assign(const basic_string&) basic_string Synonym for operator=
basic_string& assign(const basic_string& s, size_type pos, size_type n) basic_string Assigns a substring of s to *this
basic_string& assign(const charT* s, size_type n) basic_string Assigns the first n characters of s to *this .
basic_string& assign(const charT* s) basic_string Assigns a null-terminated array of characters to *this .
basic_string& assign(size_type n, charT c) Sequence Erases the existing characters and replaces them by n copies of c .
template basic_string& assign(InputIterator first, InputIterator last) Sequence Erases the existing characters and replaces them by [first, last)
basic_string& replace(size_type pos, size_type n, const basic_string& s) basic_string Replaces a substring of *this with the string s .
basic_string& replace(size_type pos, size_type n, const basic_string& s, size_type pos1, size_type n1) basic_string Replaces a substring of *this with a substring of s .
basic_string& replace(size_type pos, size_type n, const charT* s, size_type n1) basic_string Replaces a substring of *this with the first n1 characters of s .
basic_string& replace(size_type pos, size_type n, const charT* s) basic_string Replaces a substring of *this with a null-terminated character array.
basic_string& replace(size_type pos, size_type n, size_type n1, charT c) basic_string Replaces a substring of *this with n1 copies of c .
basic_string& replace(iterator first, iterator last, const basic_string& s) basic_string Replaces a substring of *this with the string s .
basic_string& replace(iterator first, iterator last, const charT* s, size_type n) basic_string Replaces a substring of *this with the first n characters of s .
basic_string& replace(iterator first, iterator last, const charT* s) basic_string Replaces a substring of *this with a null-terminated character array.
basic_string& replace(iterator first, iterator last, size_type n, charT c) basic_string Replaces a substring of *this with n copies of c .
template basic_string& replace(iterator first, iterator last, InputIterator f, InputIterator l) basic_string Replaces a substring of *this with the range [f, l)
size_type copy(charT* buf, size_type n, size_type pos = 0) const basic_string Copies a substring of *this to a buffer.
size_type find(const basic_string& s, size_type pos = 0) const basic_string Searches for s as a substring of *this , beginning at character pos of *this .
size_type find(const charT* s, size_type pos, size_type n) const basic_string Searches for the first n characters of s as a substring of *this , beginning at character pos of *this .
size_type find(const charT* s, size_type pos = 0) const basic_string Searches for a null-terminated character array as a substring of *this , beginning at character pos of *this .
size_type find(charT c, size_type pos = 0) const basic_string Searches for the character c , beginning at character position pos .
size_type rfind(const basic_string& s, size_type pos = npos) const basic_string Searches backward for s as a substring of *this , beginning at character position min(pos, size())
size_type rfind(const charT* s, size_type pos, size_type n) const basic_string Searches backward for the first n characters of s as a substring of *this , beginning at character position min(pos, size())
size_type rfind(const charT* s, size_type pos = npos) const basic_string Searches backward for a null-terminated character array as a substring of *this , beginning at character min(pos, size())
size_type rfind(charT c, size_type pos = npos) const basic_string Searches backward for the character c , beginning at character position min(pos, size() .
size_type find_first_of(const basic_string& s, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is equal to any character within s .
size_type find_first_of(const charT* s, size_type pos, size_type n) const basic_string Searches within *this , beginning at pos , for the first character that is equal to any character within the first n characters of s .
size_type find_first_of(const charT* s, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is equal to any character within s .
size_type find_first_of(charT c, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is equal to c .
size_type find_first_not_of(const basic_string& s, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is not equal to any character within s .
size_type find_first_not_of(const charT* s, size_type pos, size_type n) const basic_string Searches within *this , beginning at pos , for the first character that is not equal to any character within the first n characters of s .
size_type find_first_not_of(const charT* s, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is not equal to any character within s .
size_type find_first_not_of(charT c, size_type pos = 0) const basic_string Searches within *this , beginning at pos , for the first character that is not equal to c .
size_type find_last_of(const basic_string& s, size_type pos = npos) const basic_string Searches backward within *this , beginning at min(pos, size()) , for the first character that is equal to any character within s .
size_type find_last_of(const charT* s, size_type pos, size_type n) const basic_string Searches backward within *this , beginning at min(pos, size()) , for the first character that is equal to any character within the first n characters of s .
size_type find_last_of(const charT* s, size_type pos = npos) const basic_string Searches backward *this , beginning at min(pos, size()) , for the first character that is equal to any character within s .
size_type find_last_of(charT c, size_type pos = npos) const basic_string Searches backward *this , beginning at min(pos, size()) , for the first character that is equal to c .
size_type find_last_not_of(const basic_string& s, size_type pos = npos) const basic_string Searches backward within *this , beginning at min(pos, size()) , for the first character that is not equal to any character within s .
size_type find_last_not_of(const charT* s, size_type pos, size_type n) const basic_string Searches backward within *this , beginning at min(pos, size()) , for the first character that is not equal to any character within the first n characters of s .
size_type find_last_not_of(const charT* s, size_type pos = npos) const basic_string Searches backward *this , beginning at min(pos, size()) , for the first character that is not equal to any character within s .
size_type find_last_not_of(charT c, size_type pos = npos) const basic_string Searches backward *this , beginning at min(pos, size()) , for the first character that is not equal to c .
basic_string substr(size_type pos = 0, size_type n = npos) const basic_string Returns a substring of *this .
int compare(const basic_string& s) const basic_string Three-way lexicographical comparison of s and *this .
int compare(size_type pos, size_type n, const basic_string& s) const basic_string Three-way lexicographical comparison of s and a substring of *this .
int compare(size_type pos, size_type n, const basic_string& s, size_type pos1, size_type n1) const basic_string Three-way lexicographical comparison of a substring of s and a substring of *this
int compare(const charT* s) const basic_string Three-way lexicographical comparison of s and *this .
int compare(size_type pos, size_type n, const charT* s, size_type len = npos) const basic_string Three-way lexicographical comparison of the first min(len, traits::length(s)) characters of s and a substring of *this .
template basic_string operator+(const basic_string& s1, const basic_string& s2) basic_string String concatenation. A global function, not a member function.
template basic_string operator+(const charT* s1, const basic_string& s2) basic_string String concatenation. A global function, not a member function.
template basic_string operator+(const basic_string& s1, const charT* s2) basic_string String concatenation. A global function, not a member function.
template basic_string operator+(charT c, const basic_string& s2) basic_string String concatenation. A global function, not a member function.
template basic_string operator+(const basic_string& s1, charT c) basic_string String concatenation. A global function, not a member function.
template bool operator==(const basic_string& s1, const basic_string& s2) Container String equality. A global function, not a member function.
template bool operator==(const charT* s1, const basic_string& s2) basic_string String equality. A global function, not a member function.
template bool operator==(const basic_string& s1, const charT* s2) basic_string String equality. A global function, not a member function.
template bool operator!=(const basic_string& s1, const basic_string& s2) Container String inequality. A global function, not a member function.
template bool operator!=(const charT* s1, const basic_string& s2) basic_string String inequality. A global function, not a member function.
template bool operator!=(const basic_string& s1, const charT* s2) basic_string String inequality. A global function, not a member function.
template bool operator<(const basic_string& s1, const basic_string& s2) Container String comparison. A global function, not a member function.
template bool operator<(const charT* s1, const basic_string& s2) basic_string String comparison. A global function, not a member function.
template bool operator<(const basic_string& s1, const charT* s2) basic_string String comparison. A global function, not a member function.
template void swap(basic_string& s1, basic_string& s2) Container Swaps the contents of two strings.
template basic_istream& operator>>(basic_istream& is, basic_string& s) basic_string Reads s from the input stream is
template basic_ostream& operator<<(basic_istream& os, const basic_string& s) basic_string Writes s to the output stream os
template basic_istream& getline(basic_istream& is, basic_string& s, charT delim) basic_string Reads a string from the input stream is , stopping when it reaches delim
template basic_istream& getline(basic_istream& is, basic_string& s) basic_string Reads a single line from the input stream is
New members

These members are not defined in the Random Access Container and Sequence: requirements, but are specific to basic_string .

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Standard Template Library Programmer's Guide»

Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Standard Template Library Programmer's Guide»

Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x