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

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

Интервал:

Закладка:

Сделать

All other operations are constant time.

Models

• char_traits

• char_traits

See also

string

char_traits

Category: utilities

Component type: type

Description

The char_traits class is the default Character Traits class used by the library; it is the only predefined Character Traits class.

Example

The char_traits class is of no use by itself. It is used as a template parameter of other classes, such as the basic_string template.

Definition

Defined in the standard header string.

Template parameters
Parameter Description
charT char_traits 's value type, i.e.char_traits<>::char_type .
Model of

Character Traits

Type requirements

charT is either char or wchar_t .

(All of char_traits 's member functions are defined for arbitrary types, but some of char_traits 's members must be explicitly specialized if char_traits is to be useful for other types than char and wchar_t .)

Public base classes

None.

Members

All of char_traits 's members are static. There is never any reason to create an object of type char_traits .

Member Where defined Description
char_type Character Traits char_traits 's value type: charT .
int_type Character Traits char_traits 's int type.
pos_type Character Traits char_traits 's position type.
off_type Character Traits char_traits 's offset type
state_type Character Traits char_traits 's state type.
static void assign(char_type& c1, const char_type& c2) Character Traits Assigns c2 to c1 .
static bool eq(const char_type& c1, const char_type& c2) Character Traits Character equality.
static bool lt(const char_type& c1, const char_type& c2) Character Traits Returns true if c1 is less than c2 .
static int compare(const char_type* p1, const char_type* p2, size_t n) Character Traits Three-way lexicographical comparison, much like strncmp .
static size_t length(const char* p) Character Traits Returns length of a null-terminated array of characters.
static const char_type* find(const char_type* p, size_t n, const char_type& c) Character Traits Finds c in [p, p+n) , returning 0 if not found.
static char_type* move(char_type* s, const char_type* p, size_t n) Character Traits Copies characters from [p, p+n) to the (possibly overlapping) range [s, s+n) .
static char_type* copy(char_type* s, const char_type* p, size_t n) Character Traits Copies characters from [p, p+n) to the (non-overlapping) range [s, s+n) .
static char_type* assign(char_type* s, size_t n, char_type c) Character Traits Assigns the value c to every element in the range [s, s+n) .
static int_type eof() Character Traits Returns the value used as an EOF indicator.
static int_type not_eof(const int_type& c) Character Traits Returns a value that is not equal to eof() . Returns c unless c is equal to eof() .
static char_type to_char_type(const int_type& c) Character Traits Returns the char_type value corresponding to c , if such a value exists.
static int_type to_int_type(const char_type& c) Character Traits Returns a int_type representation of c .
static bool eq_int_type(cosnt int_type& c1, const int_type& c1) Character Traits Tests whether two int_type values are equal. If the values can also be represented as char_type , then eq and eq_int_type must be consistent with each other.
New members

None. All of char_traits 's members are defined in the Character Traits requirements.

See also

Character Traits, string

basic_string

Category: containers

Component type: type

Description

The basic_string class represents a Sequence of characters. It contains all the usual operations of a Sequence, and, additionally, it contains standard string operations such as search and concatenation.

The basic_string class is parameterized by character type, and by that type's Character Traits. Most of the time, however, there is no need to use the basic_string template directly. The types string and wstring are typedefs for, respectively, basic_string and basic_string .

Some of basic_string 's member functions use an unusual method of specifying positions and ranges. In addition to the conventional method using iterators, many of basic_string 's member functions use a single value pos of type size_type to represent a position (in which case the position is begin() + pos , and many of basic_string 's member functions use two values, pos and n , to represent a range. In that case pos is the beginning of the range and n is its size. That is, the range is [begin() + pos, begin() + pos + n) .

Note that the C++ standard does not specify the complexity of basic_string operations. In this implementation, basic_string has performance characteristics very similar to those of vector : access to a single character is O(1 ), while copy and concatenation are O(N ). By contrast, rope has very different performance characteristics: most rope operations have logarithmic complexity.

Note also that, according to the C++ standard, basic_string has very unusual iterator invalidation semantics. Iterators may be invalidated by swap , reserve , insert , and erase (and by functions that are equivalent to insert and/or erase , such as clear , resize , append , and replace ). Additionally, however, the first call to any non-const member function, including the non-const version of begin() or operator[] , may invalidate iterators. (The intent of these iterator invalidation rules is to give implementors greater freedom in implementation techniques.) In this implementation, begin() , end() , rbegin() , rend() , operator[] , c_str() , and data() do not invalidate iterators. In this implementation, iterators are only invalidated by member functions that explicitly change the string's contents.

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

Интервал:

Закладка:

Сделать

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