size() and length() function is equal.
http://en.cppreference.com/w/cpp/string/basic_string
std::basic_string
Defined in header <string> | ||
template< class CharT, | ||
The class template basic_string
stores and manipulates sequences of char-like objects. The class is dependent neither on the character type nor on the nature of operations on that type. The definitions of the operations are supplied via the Traits
template parameter - a specialization of std::char_traits or a compatible traits class.
The elements of a | (since C++11) |
Several typedefs for common character types are provided:
Defined in header <string> | |
Type | Definition |
std::string | std::basic_string<char> |
std::wstring | std::basic_string<wchar_t> |
std::u16string (C++11) | std::basic_string<char16_t> |
std::u32string (C++11) | std::basic_string<char32_t> |
Template parameters
CharT | - | character type |
Traits | - | traits class specifying the operations on the character type |
Allocator | - | Allocator type used to allocate internal storage |
Member types
Member type | Definition |
traits_type | Traits |
value_type | Traits::char_type |
allocator_type | Allocator |
size_type | Unsigned integral type (usually std::size_t) |
difference_type | Signed integer type (usually std::ptrdiff_t) |
reference | Allocator::reference (until C++11)value_type& (since C++11) |
const_reference | Allocator::const_reference (until C++11)const value_type& (since C++11) |
pointer | Allocator::pointer (until C++11)std::allocator_traits<Allocator>::pointer (since C++11) |
const_pointer | Allocator::const_pointer (until C++11) std::allocator_traits<Allocator>::const_pointer (since C++11) |
iterator | RandomAccessIterator |
const_iterator | Constant random access iterator |
reverse_iterator | std::reverse_iterator<iterator> |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
Member functions
constructs a basic_string (public member function) | |
assigns values to the string (public member function) | |
assign characters to a string (public member function) | |
returns the associated allocator (public member function) | |
Element access | |
access specified character with bounds checking (public member function) | |
access specified character (public member function) | |
(C++11) | accesses the first character (public member function) |
(C++11) | accesses the last character (public member function) |
returns a pointer to the first character of a string (public member function) | |
returns a non-modifiable standard C character array version of the string (public member function) | |
Iterators | |
(C++11) | returns an iterator to the beginning (public member function) |
(C++11) | returns an iterator to the end (public member function) |
(C++11) | returns a reverse iterator to the beginning (public member function) |
(C++11) | returns a reverse iterator to the end (public member function) |
Capacity | |
checks whether the string is empty (public member function) | |
returns the number of characters (public member function) | |
returns the maximum number of characters (public member function) | |
reserves storage (public member function) | |
returns the number of characters that can be held in currently allocated storage (public member function) | |
(C++11) | reduces memory usage by freeing unused memory (public member function) |
Operations | |
clears the contents (public member function) | |
inserts characters (public member function) | |
removes characters (public member function) | |
appends a character to the end (public member function) | |
(C++11) | removes the last character (public member function) |
appends characters to the end (public member function) | |
appends characters to the end (public member function) | |
compares two strings (public member function) | |
replaces specified portion of a string (public member function) | |
returns a substring (public member function) | |
copies characters (public member function) | |
changes the number of characters stored (public member function) | |
swaps the contents (public member function) | |
Search | |
find characters in the string (public member function) | |
find the last occurrence of a substring (public member function) | |
find first occurrence of characters (public member function) | |
find first absence of characters (public member function) | |
find last occurrence of characters (public member function) | |
find last absence of characters (public member function) | |
Constants | |
[static] | special value. The exact meaning depends on the context (public static member constant) |
Non-member functions
concatenates two strings or a string and a char (function template) | |
lexicographically compares two strings (function template) | |
specializes the std::swap algorithm (function template) | |
Input/output | |
performs stream input and output on strings (function template) | |
read data from an I/O stream into a string (function) | |
Numeric conversions | |
(C++11)(C++11)(C++11) | converts a string to a signed integer (function) |
(C++11)(C++11) | converts a string to an unsigned integer (function) |
(C++11)(C++11)(C++11) | converts a string to a floating point value (function) |
(C++11) | converts an integral or floating point value to string (function) |
(C++11) | converts an integral or floating point value to wstring (function) |
Literals
Defined in inline namespace std::literals::string_literals | |
(C++14) | Converts a character array literal to basic_string (function) |
Helper classes
(C++11)(C++11)(C++11)(C++11) | hash support for strings (class template specialization) |
'C, C++' 카테고리의 다른 글
[C, C++] More Effective C++ Item28 : Smart Pointer (0) | 2014.03.30 |
---|---|
[C++][추후 추가해야 함] More Effective C++ Item 26 : 클래스 인스턴스의 개수를 의도대로 제한하는 방법 (0) | 2014.03.16 |
[C++] More Effective C++ Item 25 : 생성자 함수와 비 멤버 함수를 가상 함수처럼 만드는 방법 (0) | 2014.03.16 |
[C, C++] Formatting std::string (0) | 2014.03.03 |
How to output long long or int64? (2) | 2014.03.03 |
[Windows32 API] Dialog 박스와 CreateWindow 같이 쓸 때 (0) | 2013.05.13 |
[C, C++][Windows] 윈도우 종료시 콜스택 [KernelBase.dll 에 첫째 예외가 있습니다] (0) | 2013.05.09 |
[C, C++][스크랩] #pragma warning (0) | 2013.04.18 |
[C++] 64비트 환경과 INT_PTR, int (0) | 2013.02.09 |
[C++] (Exception) std::bad_alloc (0) | 2013.02.07 |