이름공간
변수
행위

Strings library

cppreference.com
< cpp
P12 (토론 | 기여) 사용자의 2013년 8월 19일 (월) 05:27 판

(비교) ← 이전 판 | 최신판 (비교) | 다음 판 → (비교)

The C++ strings library includes support for two general types of strings:

  • std::basic_string - a templated class designed to manipulate strings of any character type.
  • Null-terminated strings - arrays of characters terminated by a special null character.

목차

std::basic_string

The templated class std::basic_string generalizes how sequences of characters are manipulated and stored. String creation, manipulation, and destruction are all handled by a convenient set of class methods and related functions.

Several specializations of std::basic_string are provided for commonly-used types:

<string> 헤더에 정의됨.
Type Definition
std::string std::basic_string<char>
std::wstring std::basic_string<wchar_t>
std::u16string std::basic_string<char16_t>
std::u32string std::basic_string<char32_t>

Null-terminated strings

Null-terminated strings are arrays of characters that are terminated by a special null character. C++ provides functions to create, inspect, and modify null-terminated strings.

There are three types of null-terminated strings:

Additional support

std::char_traits

The string library also provides class template std::char_traits that defines types and functions for std::basic_string. The following specializations are defined:

<string> 에 정의되어 있음.
template<> class char_traits<std::string>;

template<> class char_traits<std::wstring>;
template<> class char_traits<std::u16string>;

template<> class char_traits<std::u32string>;


(since C++11)
(since C++11)