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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать
Member Description
static const size_type npos The largest possible value of type size_type . That is, size_type(-1) .
size_type length() const Equivalent to size() .
size_type capacity() const Number of elements for which memory has been allocated. That is, the size to which the string can grow before memory must be reallocated. capacity() is always greater than or equal to size() .
const charT* c_str() const Returns a pointer to a null-terminated array of characters representing the string's contents. For any string s it is guaranteed that the first s.size() characters in the array pointed to by s.c_str() are equal to the character in s , and that s.c_str()[s.size()] is a null character. Note, however, that it not necessarily the first null character. Characters within a string are permitted to be null.
const charT* data() const Returns a pointer to an array of characters, not necessarily null-terminated, representing the string's contents. data() is permitted, but not required, to be identical to c_str() . The first size() characters of that array are guaranteed to be identical to the characters in *this . The return value of data() is never a null pointer, even if size() is zero.
basic_string(const basic_string& s, size_type pos = 0, size_type n = npos) Constructs a string from a substring of s . The substring begins at character position pos and terminates at character position pos + n or at the end of s , whichever comes first. This constructor throws out_of_range if pos > s.size() . Note that when pos and n have their default values, this is just a copy constructor.
basic_string(const charT* s) Equivalent to basic_string(s, s + traits::length(s)) .
basic_string(const charT* s, size_type n) Equivalent to basic_string(s, s + n) .
basic_string& operator=(const charT* s) Equivalent to operator=(basic_string(s)) .
basic_string& operator=(charT c) Assigns to *this a string whose size is 1 and whose contents is the single character c .
void reserve(size_t n) Requests that the string's capacity be changed; the postcondition for this member function is that, after it is called, capacity() >= n . You may request that a string decrease its capacity by calling reserve() with an argument less than the current capacity. (If you call reserve() with an argument less than the string's size, however, the capacity will only be reduced to size() . A string's size can never be greater than its capacity.) reserve() throws length_error if n > max_size() .
basic_string& insert(size_type pos, const basic_string& s) If pos > size() , throws out_of_range . Otherwise, equivalent to insert(begin() + pos, s.begin(), s.end()) .
basic_string& insert(size_type pos, const basic_string& s, size_type pos1, size_type n) If pos > size() or pos1 > s.size() , throws out_of_range . Otherwise, equivalent to insert(begin() + pos, s.begin() + pos1, s.begin() + pos1 + min(n, s.size() – pos1)) .
basic_string& insert(size_type pos, const charT* s) If pos > size() , throws out_of_range . Otherwise, equivalent to insert(begin() + pos, s, s + traits::length(s))
basic_string& insert(size_type pos, const charT* s, size_type n) If pos > size() , throws out_of_range . Otherwise, equivalent to insert(begin() + pos, s, s + n) .
basic_string& insert(size_type pos, size_type n, charT c) If pos > size() , throws out_of_range . Otherwise, equivalent to insert(begin() + pos, n, c) .
basic_string& append(const basic_string& s) Equivalent to insert(end(), s.begin(), s.end()) .
basic_string& append(const basic_string& s, size_type pos, size_type n) If pos > s.size() , throws out_of_range . Otherwise, equivalent to insert(end(), s.begin() + pos, s.begin() + pos + min(n, s.size() – pos)) .
basic_string& append(const charT* s) Equivalent to insert(end(), s, s + traits::length(s)) .
basic_string& append(const charT* s, size_type n) Equivalent to insert(end(), s, s + n) .
basic_string& append(size_type n, charT c) Equivalent to insert(end(), n, c) .
template basic_string& append(InputIterator first, InputIterator last) Equivalent to insert(end(), first, last) .
void push_back(charT c) Equivalent to insert(end(), c)
basic_string& operator+=(const basic_string& s) Equivalent to append(s) .
basic_string& operator+=(const charT* s) Equivalent to append(s)
basic_string& operator+=(charT c) Equivalent to push_back(c)
basic_string& erase(size_type pos = 0, size_type n = npos) If pos > size() , throws out_of_range . Otherwise, equivalent to erase(begin() + pos, begin() + pos + min(n, size() – pos)) .
basic_string& assign(const basic_string& s) Synonym for operator=
basic_string& assign(const basic_string& s, size_type pos, size_type n) Equivalent to (but probably faster than) clear() followed by insert(0, s, pos, n) .
basic_string& assign(const charT* s, size_type n) Equivalent to (but probably faster than) clear() followed by insert(0, s, n) .
basic_string& assign(const charT* s) Equivalent to (but probably faster than) clear() followed by insert(0, s) .
basic_string& replace(size_type pos, size_type n, const basic_string& s) Equivalent to erase(pos, n) followed by insert(pos, s) .
basic_string& replace(size_type pos, size_type n, const basic_string& s, size_type pos1, size_type n1) Equivalent to erase(pos, n) followed by insert(pos, s, pos1, n1) .
basic_string& replace(size_type pos, size_type n, const charT* s, size_type n1) Equivalent to erase(pos, n) followed by insert(pos, s, n1) .
basic_string& replace(size_type pos, size_type n, const charT* s) Equivalent to erase(pos, n) followed by insert(pos, s) .
basic_string& replace(size_type pos, size_type n, size_type n1, charT c) Equivalent to erase(pos, n) followed by insert(pos, n1, c) .
basic_string& replace(iterator first, iterator last, const basic_string& s) Equivalent to insert(erase(first, last), s.begin(), s.end()) .
basic_string& replace(iterator first, iterator last, const charT* s, size_type n) Equivalent to insert(erase(first, last), s, s + n) .
basic_string& replace(iterator first, iterator last, const charT* s) Equivalent to insert(erase(first, last), s, s + traits::length(s)) .
basic_string& replace(iterator first, iterator last, size_type n, charT c) Equivalent to insert(erase(first, last), n, c) .
template basic_string& replace(iterator first, iterator last, InputIterator f, InputIterator l) Equivalent to insert(erase(first, last), f, l) .
size_type copy(charT* buf, size_type n, size_type pos = 0) const Copies at most n characters from *this to a character array. Throws out_of_range if pos > size() . Otherwise, equivalent to copy(begin() + pos, begin() + pos + min(n, size()), buf) . Note that this member function does nothing other than copy characters from *this to buf ; in particular, it does not terminate buf with a null character.
size_type find(const basic_string& s, size_type pos = 0) const Searches for s as a substring of *this , beginning at character position pos . It is almost the same as search , except that search tests elements for equality using operator== or a user-provided function object, while this member function uses traits::eq . Returns the lowest character position N such that pos <= N and pos + s.size() <= size() and such that, for every i less than s.size() , (*this)[N + i] compares equal to s[i] . Returns npos if no such position N exists. Note that it is legal to call this member function with arguments such that s.size() > size() – pos , but such a search will always fail.
size_type find(const charT* s, size_type pos, size_type n) const Searches for the first n characters of s as a substring of *this , beginning at character pos of *this . This is equivalent to find(basic_string(s, n), pos) .
size_type find(const charT* s, size_type pos = 0) const Searches for a null-terminated character array as a substring of *this , beginning at character pos of *this . This is equivalent to find(basic_string(s), pos) .
size_type find(charT c, size_type pos = 0) const Searches for the character c , beginning at character position pos . That is, returns the first character position N greater than or equal to pos , and less than size() , such that (*this)[N] compares equal to c . Returns npos if no such character position N exists.
size_type rfind(const basic_string& s, size_type pos = npos) const Searches backward for s as a substring of *this . It is almost the same as find_end , except that find_end tests elements for equality using operator== or a user-provided function object, while this member function uses traits::eq . This member function returns the largest character position N such that N <= pos and N + s.size() <= size() , and such that, for every i less than s.size() , (*this)[N + i] compares equal to s[i] . Returns npos if no such position N exists. Note that it is legal to call this member function with arguments such that s.size() > size() , but such a search will always fail.
size_type rfind(const charT* s, size_type pos, size_type n) const Searches backward for the first n characters of s as a substring of *this . Equivalent to rfind(basic_string(s, n), pos) .
size_type rfind(const charT* s, size_type pos = npos) const Searches backward for a null-terminated character array as a substring of *this . Equivalent to rfind(basic_string(s), pos) .
size_type rfind(charT c, size_type pos = npos) const Searches backward for the character c . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] compares equal to c . Returns npos if no such character position exists.
size_type find_first_of(const basic_string& s, size_type pos = 0) const Searches within *this , beginning at pos , for the first character that is equal to any character within s . This is similar to the standard algorithm find_first_of , but differs because find_first_of compares characters using operator== or a user-provided function object, while this member function uses traits::eq . Returns the smallest character position N such that pos <= N < size() , and such that (*this)[N] compares equal to some character within s . Returns npos if no such character position exists.
size_type find_first_of(const charT* s, size_type pos, size_type n) const Searches within *this , beginning at pos , for the first character that is equal to any character within the range [s, s+n) . That is, returns the smallest character position N such that pos <= N < size() , and such that (*this)[N] compares equal to some character in [s, s+n) . Returns npos if no such character position exists.
size_type find_first_of(const charT* s, size_type pos = 0) const Equivalent to find_first_of(s, pos, traits::length(s)) .
size_type find_first_of(charT c, size_type pos = 0) const Equivalent to find(c, pos) .
size_type find_first_not_of(const basic_string& s, size_type pos = 0) const Searches within *this , beginning at pos , for the first character that is not equal to any character within s . Returns the smallest character position N such that pos <= N < size() , and such that (*this)[N] does not compare equal to any character within s . Returns npos if no such character position exists.
size_type find_first_not_of(const charT* s, size_type pos, size_type n) const Searches within *this , beginning at pos , for the first character that is not equal to any character within the range [s, s+n) . That is, returns the smallest character position N such that pos <= N < size() , and such that (*this)[N] does not compare equal to any character in [s, s+n) . Returns npos if no such character position exists.
size_type find_first_not_of(const charT* s, size_type pos = 0) const Equivalent to find_first_not_of(s, pos, traits::length(s)) .
size_type find_first_not_of(charT c, size_type pos = 0) const Returns the smallest character position N such that pos <= N < size() , and such that (*this)[N] does not compare equal to c . Returns npos if no such character position exists.
size_type find_last_of(const basic_string& s, size_type pos = npos) const Searches backward within *this for the first character that is equal to any character within s . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] compares equal to some character within s . Returns npos if no such character position exists.
size_type find_last_of(const charT* s, size_type pos, size_type n) const Searches backward within *this for the first character that is equal to any character within the range [s, s+n) . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] compares equal to some character within [s, s+n) . Returns npos if no such character position exists.
size_type find_last_of(const charT* s, size_type pos = npos) const Equivalent to find_last_of(s, pos, traits::length(s)) .
size_type find_last_of(charT c, size_type pos = npos) const Equivalent to rfind(c, pos) .
size_type find_last_not_of(const basic_string& s, size_type pos = npos) const Searches backward within *this for the first character that is not equal to any character within s . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] does not compare equal to any character within s . Returns npos if no such character position exists.
size_type find_last_not_of(const charT* s, size_type pos, size_type n) const Searches backward within *this for the first character that is not equal to any character within [s, s+n) . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] does not compare equal to any character within [s, s+n) . Returns npos if no such character position exists.
size_type find_last_not_of(const charT* s, size_type pos = npos) const Equivalent to find_last_of(s, pos, traits::length(s)) .
size_type find_last_not_of(charT c, size_type pos = npos) const Searches backward *this for the first character that is not equal to c . That is, returns the largest character position N such that N <= pos and N < size() , and such that (*this)[N] does not compare equal to c .
basic_string substr(size_type pos = 0, size_type n = npos) const Equivalent to basic_string(*this, pos, n) .
int compare(const basic_string& s) const Three-way lexicographical comparison of s and *this , much like strcmp . If traits::compare(data, s.data(), min(size(), s.size())) is nonzero, then it returns that nonzero value. Otherwise returns a negative number if size() < s.size() , a positive number if size() > s.size() , and zero if the two are equal.
int compare(size_type pos, size_type n, const basic_string& s) const Three-way lexicographical comparison of s and a substring of *this . Equivalent to basic_string(*this, pos, n).compare(s) .
int compare(size_type pos, size_type n, const basic_string& s, size_type pos1, size_type n1) const Three-way lexicographical comparison of a substring of s and a substring of *this . Equivalent to basic_string(*this, pos, n).compare(basic_string(s, pos1, n1)) .
int compare(const charT* s) const Three-way lexicographical comparison of s and *this . Equivalent to compare(basic_string(s)) .
int compare(size_type pos, size_type n, const charT* s, size_type len = npos) const Three-way lexicographical comparison of the first min(len, traits::length(s) characters of s and a substring of *this . Equivalent to basic_string(*this, pos, n).compare(basic_string(s, min(len, traits::length(s)))) .
template basic_string operator+(const basic_string& s1, const basic_string& s2) String concatenation. Equivalent to creating a temporary copy of s , appending s2 , and then returning the temporary copy.
template basic_string operator+(const charT* s1, const basic_string& s2) String concatenation. Equivalent to creating a temporary basic_string object from s1 , appending s2 , and then returning the temporary object.
template basic_string operator+(const basic_string& s1, const charT* s2) String concatenation. Equivalent to creating a temporary copy of s , appending s2 , and then returning the temporary copy.
template basic_string operator+(charT c, const basic_string& s2) String concatenation. Equivalent to creating a temporary object with the constructor basic_string(1, c) , appending s2 , and then returning the temporary object.
template basic_string operator+(const basic_string& s1, charT c) String concatenation. Equivalent to creating a temporary object, appending c with push_back , and then returning the temporary object.
template bool operator==(const charT* s1, const basic_string& s2) String equality. Equivalent to basic_string(s1).compare(s2) == 0 .
template bool operator==(const basic_string& s1, const charT* s2) String equality. Equivalent to basic_string(s1).compare(s2) == 0 .
template bool operator!=(const charT* s1, const basic_string& s2) String inequality. Equivalent to basic_string(s1).compare(s2) == 0 .
template bool operator!=(const basic_string& s1, const charT* s2) String inequality. Equivalent to !(s1 == s2) .
template bool operator<(const charT* s1, const basic_string& s2) String comparison. Equivalent to !(s1 == s2) .
template bool operator<(const basic_string& s1, const charT* s2) String comparison. Equivalent to !(s1 == s2) .
template basic_istream& operator>>(basic_istream& is, basic_string& s) Reads s from the input stream is . Specifically, it skips whitespace, and then replaces the contents of s with characters read from the input stream. It continues reading characters until it encounters a whitespace character (in which case that character is not extracted), or until end-of-file, or, if is.width() is nonzero, until it has read is.width() characters. This member function resets is.width() to zero.
template basic_ostream& operator>>(basic_istream& is, const basic_string& s) Writes s to the output stream is . It writes max(s.size(), is.width()) characters, padding as necessary. This member function resets is.width() to zero.
template basic_istream& getline(basic_istream& is, basic_string& s, charT delim) Replaces the contents of s with characters read from the input stream. It continues reading characters until it encounters the character delim (in which case that character is extracted but not stored in s ), or until end of file. Note that getline , unlike operator>> , does not skip whitespace. As the name suggests, it is most commonly used to read an entire line of text precisely as the line appears in an input file.
template basic_istream& getline(basic_istream& is, basic_string& s) Equivalent to getline(is, s, is.widen('\n\)) .
See also

rope , vector , Character Traits

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

Интервал:

Закладка:

Сделать

Похожие книги на «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