#!if 문서명2 != null
, [[문자열]]#!if 문서명3 != null
, [[]]#!if 문서명4 != null
, [[]]#!if 문서명5 != null
, [[]]#!if 문서명6 != null
, [[]]1. 개요
||<-12><tablewidth=80%><tablebordercolor=#20b580><tablebgcolor=#090f0a,#050b09><tablecolor=#a8a8a8,#c1c1c1><rowcolor=#d7d7d7,#a1a1a1>
<string> ||| <bgcolor=#20b580> | |||||||||||||
| |||||||||||||
동적 할당을 사용하고 수정할 수 있는 문자열 클래스. 내부적으로 문자열에 대한 포인터와 길이를 함께 저장한다.
| <bgcolor=#20b580> | ||||||||||||
| |||||||||||||
| |||||||||||||
| C++20 | ||||||||||||
| |||||||||||||
| |||||||||||||
std::string<CharType, [Traits], [Allocator]>의 각각의 문자 자료형에 대하여 특수화된 클래스. | |||||||||||||
| <bgcolor=#20b580> | |||||||||||||
<string>기본 클래스 템플릿
std::basic_string<CharType, [Traits], [Allocator]>, 그리고 여기에서 파생되는 std::string, std::wstring 등은 모든 유형의 문자열을 가리키는 클래스다 [이하].2. std::basic_string
||||<tablewidth=100%><tablebordercolor=#20b580><tablebgcolor=#090f0a,#050b09><tablecolor=#a8a8a8,#c1c1c1><rowcolor=#d7d7d7,#a1a1a1> [include(틀:C++ 요소, head_keyword=class, ns1=std, pre1_t=basic_string, body_tmpopen=1, arg1_t=CharType, arg2_t=[Traits], arg3_t=[Allocator])] ||
별도의 설명이 필요없는 멤버 함수를 수록했다. 스트링 클래스는 수정할 수 있으며 벡터처럼 원소의 추가와 삭제를 할 수 있다. 위의 표에서 크기(size, capacity)와 길이(length)를 구분해서 기재했다. 크기는 내부 문자열 버퍼가 할당된 메모리의 바이트 크기이다, 길이는 내부 문자열 버퍼에 들어있는 어떤 문자열의 길이를 나타내는 size_t 값이다.
| |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 길이는 0이다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 문자를 맨 뒤에 하나 추가한다. 만약 내부 문자열 버퍼가 수정되면 이전에 얻었던 순회자를 폐기한다. | |||||||||||
| |||||||||||
| 맨 뒤의 문자를 하나 제거한다. 빈 문자열이면 정의되지 않은 동작이며, C++26부터는 런타임 오류다. 만약 내부 문자열 버퍼가 수정되면 이전에 얻었던 순회자를 폐기한다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| [include(틀:C++ 요소, kw1=const, pre1_t=CharType, pre_post=&, body_mf=operator[], arg1_t=size_type, arg1_param=index, body_bopen=1, body_spec1=const, last=;)] | |||||||||||
| 문자열의 특정 위치에서 문자를 하나 읽는다. 내부 문자열 내용의 길이를 벗어나면 정의되지 않은 동작이며, C++26부터는 런타임 오류다. | |||||||||||
| |||||||||||
| |||||||||||
| 문자열의 맨 앞 또는 맨 뒤에서 문자를 하나 읽는다. 내용이 빈 문자열이면 정의되지 않은 동작이며, C++26부터는 런타임 오류다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 지정한 크기 만큼 내부 문자열 버퍼를 동적 할당한다. 이때 지정한 크기가 원래 버퍼의 크기보다 작거나 같으면 아무 동작도 하지 않는다. 만약 내부 문자열 버퍼가 수정되면 이전에 얻었던 순회자를 폐기한다. | |||||||||||
| |||||||||||
| |||||||||||
| 내부 문자열 내용의 길이를 변경한다. 지정한 길이가 원래 문자열 버퍼의 크기보다 크면 새로 할당한다. 만약 지정한 길이가 원래 문자열 버퍼의 크기보다 작으면 내부 문자열 버퍼를 축소한다. 만약 내부 문자열 버퍼가 수정되면 이전에 얻었던 순회자를 폐기한다. | |||||||||||
| |||||||||||
| 내부 문자열 버퍼의 크기를 문자열 내용의 길이와 맞게 축소한다. 이때 내부 문자열 버퍼가 수정될 수 있으며, 이전에 얻었던 순회자를 폐기한다. | |||||||||||
| |||||||||||
내부 문자열 내용을 0으로 쓴다. 내부 문자열 버퍼는 수정하지 않으며, 따라서 noexcept이다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 내부 문자열 버퍼의 크기를 반환한다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 내부 문자열 내용이 빈 문자열인지 여부를 반환한다. | |||||||||||
| |||||||||||
| |||||||||||
| 내부 문자열 내용의 길이를 반환한다. | |||||||||||
| |||||||||||
자료형 size_type이 가질 수 있는 가장 큰 수를 반환한다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| 수정할 수 없는 내부 문자열 버퍼의 포인터를 반환한다. | |||||||||||
| |||||||||||
수정할 수 없는 내부 문자열 버퍼의 포인터를 반환한다. c_str()와 같은 동작을 한다. | |||||||||||
| |||||||||||
| 수정할 수 있는 내부 문자열 버퍼의 포인터를 반환한다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| 스트링 클래스도 하나의 범위이다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
#!syntax cpp
struct Dog
{
void SetName(const std::string& name) { myName = name; }
void SetName(std::string&& name) { myName = std::move(name); }
[[nodiscard]]
const std::string& GetName() const& noexcept { return myName; }
[[nodiscard]]
std::string&& GetName() && noexcept { return std::move(myName); }
std::string myName;
};
일반적으로 문자열을 클래스 멤버로 쓰기 위해서는 상기 코드와 같이 lvalue와 rvalue 둘 모두에 대하여 오버로딩해야한다. 그렇지 않으면 스트링의 인스턴스가 계속 복사되면서 성능 문제 또는 오류 발생의 가능성이 있다. getter 함수의 경우에도 한정자를 붙여야 한다.그러나 오버로딩을 잘 해주어도 동적 할당을 피할 수 없기 때문에 만약 문자열을 수정하지 않아도 되는 상황이면
std::string_view를 쓰는 걸 권장한다.3. 유틸리티
||<tablewidth=80%><tablebordercolor=#20b580><tablebgcolor=#090f0a,#050b09><tablecolor=#a8a8a8,#c1c1c1><rowcolor=#d7d7d7,#a1a1a1>[include(틀:C++ 요소, kw2=int, body_ns=std, body_f=stoi, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], arg3_t_kw=int, arg3_param=[base], body_bopen=1, last=;)]||<width=10%><|11>C++11||
이 함수는 | [include(틀:C++ 요소, kw2=long, body_ns=std, body_f=stol, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], arg3_t_kw=int, arg3_param=[base], body_bopen=1, last=;)] | |||||||||||
| [include(틀:C++ 요소, kw2=long long, body_ns=std, body_f=stoll, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], arg3_t_kw=int, arg3_param=[base], body_bopen=1, last=;)] | |||||||||||
스트링 클래스의 내용을 base진법의 부호있는 정수로 변환한다.
| |||||||||||
| [include(틀:C++ 요소, kw2=unsigned long, body_ns=std, body_f=stoul, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], arg3_t_kw=int, arg3_param=[base], body_bopen=1, last=;)] | |||||||||||
| [include(틀:C++ 요소, kw2=unsigned long long, body_ns=std, body_f=stoull, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], arg3_t_kw=int, arg3_param=[base], body_bopen=1, last=;)] | |||||||||||
스트링 클래스의 내용을 base진법의 부호없는 정수로 변환한다.
| |||||||||||
| [include(틀:C++ 요소, kw2=float, body_ns=std, body_f=stof, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], body_bopen=1, last=;)] | |||||||||||
| [include(틀:C++ 요소, kw2=double, body_ns=std, body_f=stod, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], body_bopen=1, last=;)] | |||||||||||
| [include(틀:C++ 요소, kw2=long double, body_ns=std, body_f=stold, arg1_kw=const, arg1_ns=std, arg1_t=string, arg1_t_post=&, arg1_param=str, arg2_t=size_t, arg2_t_post=*, arg2_param=[position], body_bopen=1, last=;)] | |||||||||||
스트링 클래스의 내용을 부동 소수점으로 변환한다.
| |||||||||||
| <bgcolor=#20b580> | |||||||||||
std::wstring에 대해서도 오버로딩을 제공한다.||<tablewidth=80%><tablebordercolor=#20b580><tablebgcolor=#090f0a,#050b09><tablecolor=#a8a8a8,#c1c1c1><rowcolor=#d7d7d7,#a1a1a1>
||<width=10%><|10>C++11||
#!if attribute != null
[[C++/문법/특성|{{{#a8a8a8 {{{[[]]}}}}}}]]{{{ }}}#!if attribute_lnk != null
[[C++/문법/특성#|{{{#a8a8a8 {{{[[]]}}}}}}]]{{{ }}}#!if head_keyword != null
##======================================= include and import
'''{{{#569cd6 {{{}}}}}}'''#!if import != null
'''{{{#569cd6 {{{import}}}}}}'''{{{#c8865e {{{ <>}}}}}}{{{;}}}#!if include != null
{{{#include }}}#!if (template_available = (template_p0 != null || template_v0 != null || template_p1 != null || template_v1 != null || template_p2 != null || template_v2 != null || template_p3 != null || template_v3 != null)) || template_last_label != null
##======================================= template parameter 0
##======================================= template parameter 0 concept
{{{<}}}{{{#!if template_p0_default != null || template_v0_default != null
{{{[}}}}}}{{{#!if template_concept0_available = (template_cpt0 != null)
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if template_concept0_p0 != null || template_concept0_v0 != null || template_concept0_last_label != null
{{{<}}}{{{#!if template_concept0_p0 != null
{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept0_v0 != null
{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept0_p1 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept0_v1 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept0_p2 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept0_v2 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept0_last_label != null
{{{}}}}}}{{{>}}}}}}}}}{{{#!if template_p0 != null
{{{#!if !template_concept0_available
'''{{{#569cd6 {{{typename}}}}}}'''}}}{{{#!if template_p0_post != null
{{{}}}}}}{{{#4ec9b0,#6fdbba {{{ }}}}}}}}}{{{#!if template_p0_default != null
{{{ = }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_v0 != null
{{{#4ec9b0,#6fdbba {{{ }}}}}}{{{#!if template_p0_post != null
{{{ }}}}}}{{{#ffffff '''{{{}}}'''}}}}}}{{{#!if template_v0_default != null
{{{ = }}}{{{#b5cea8 {{{}}}}}}}}}{{{#!if template_p0_default != null || template_v0_default != null
{{{]}}}}}}{{{#!if template_p1 != null || template_v1 != null
##======================================= template parameter 1
{{{, }}}}}}{{{#!if template_p1_default != null || template_v1_default != null
{{{[}}}}}}{{{#!if template_concept1_available = (template_cpt1 != null)
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if template_concept1_p0 != null || template_concept1_v0 != null || template_concept1_last_label != null
{{{<}}}{{{#!if template_concept1_p0 != null
{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept1_v0 != null
{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept1_p1 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept1_v1 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept1_p2 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept1_v2 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept1_last_label != null
{{{}}}}}}{{{>}}}}}}}}}{{{#!if template_p1 != null
{{{#!if !template_concept1_available
'''{{{#569cd6 {{{typename}}}}}}'''}}}{{{#!if template_p1_post != null
{{{ }}}}}}{{{#4ec9b0,#6fdbba {{{ }}}}}}}}}{{{#!if template_p1_default != null
{{{ = }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_v1 != null
{{{#4ec9b0,#6fdbba {{{ }}}}}}{{{#!if template_p1_post != null
{{{}}}}}}{{{#ffffff '''{{{}}}'''}}}}}}{{{#!if template_p1_default != null || template_v1_default != null
{{{]}}}}}}{{{#!if template_p2 != null || template_v2 != null
##======================================= template parameter 2
{{{, }}}}}}{{{#!if template_p2_default != null || template_v2_default != null
{{{[}}}}}}{{{#!if template_concept2_available = (template_cpt2 != null)
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if template_concept2_p0 != null || template_concept2_v0 != null || template_concept2_last_label != null
{{{<}}}{{{#!if template_concept2_p0 != null
{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept2_v0 != null
{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept2_p1 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept2_v1 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept2_p2 != null
{{{, }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_concept2_v2 != null
{{{, }}}{{{#ffffff {{{}}}}}}}}}{{{#!if template_concept2_last_label != null
{{{}}}}}}{{{>}}}}}}}}}{{{#!if template_p2 != null
{{{#!if !template_concept2_available
'''{{{#569cd6 {{{typename}}}}}}'''}}}{{{#!if template_p2_post != null
{{{}}}}}}{{{#4ec9b0,#6fdbba {{{ }}}}}}}}}{{{#!if template_p2_default != null
{{{ = }}}{{{#4ec9b0,#6fdbba {{{}}}}}}}}}{{{#!if template_v2 != null
{{{#4ec9b0,#6fdbba {{{ }}}}}}{{{#!if template_p2_post != null
{{{ }}}}}}{{{#ffffff '''{{{}}}'''}}}}}}{{{#!if template_v2_default != null
{{{ = }}}{{{#b5cea8 {{{}}}}}}}}}{{{#!if template_p2_default != null || template_v2_default != null
{{{]}}}}}}{{{#!if template_last_label == null
{{{>}}}}}}{{{#!if template_last_label != null
##======================================= template parameters end
{{{>}}}}}}#!if pre_available = (kw1 != null || kw1_post != null || kw2 != null || kw2_post != null || cls_attribute != null || cls_attribute_lnk != null || ns_end != null || pre1_t != null || pre2_t != null || pre_e != null)
#!if ns_available = (ns != null || ns1 != null || ns2 != null || ns3 != null)
#!if body_available = (body_ns || body_number != null || body_string != null || body_v != null || body_gv != null || body_f != null || body_mv != null || body_mf != null || body_static_mv != null || body_static_mf != null || body_post != null)
#!if head_keyword != null && (pre_available || body_available || ns != null || ns1 != null)
{{{ }}}#!if fn_attribute != null
[[C++/문법/특성|{{{#a8a8a8 {{{[[]]}}}}}}]]{{{ }}}#!if fn_attribute_lnk != null
[[C++/문법/특성#|{{{#a8a8a8 {{{[[]]}}}}}}]]{{{ }}}#!if kw1 != null
'''{{{#569cd6 {{{contexpr}}}}}}'''{{{#!if kw1_post != null
{{{}}}}}}{{{#!if kw1_post == null && kw2 != null
{{{ }}}}}}#!if kw2 != null
'''{{{#CornFlowerBlue {{{long long}}}}}}'''{{{#!if kw2_post != null
{{{&&}}}}}}{{{#!if kw2_post == null && (cls_attribute != null || cls_attribute_lnk != null)
{{{ }}}}}}#!if cls_attribute != null
[[C++/문법/특성|{{{#a8a8a8 {{{[[]]}}}}}}]]#!if cls_attribute_lnk != null
[[C++/문법/특성#|{{{#a8a8a8 {{{[[]]}}}}}}]]#!if (head_keyword != null || pre_available || cls_attribute != null || cls_attribute_lnk != null) && (body_available || ns_available)
##======================================= Namespaces
{{{ }}}#!if ns != null
'''{{{#58fafe {{{}}}}}}'''#!if ns1 != null
{{{#!if ns1_pre_kw != null
'''{{{#569cd6 {{{inline }}}}}}'''}}}'''{{{#58fafe {{{std}}}}}}'''#!if ns1_post != null
{{{ }}}#!if ns2 != null
{{{#!if ns1_post == null
{{{::}}}}}}{{{#!if ns2_pre_kw != null
'''{{{#569cd6 {{{inline }}}}}}'''}}}'''{{{#58fafe {{{chrono}}}}}}'''#!if ns2_post != null
{{{ }}}#!if ns3 != null
{{{#!if ns2_post == null
{{{::}}}}}}{{{#!if ns3_pre_kw != null
'''{{{#569cd6 {{{inline }}}}}}'''}}}'''{{{#58fafe {{{chrono_literals}}}}}}'''#!if ns3_post != null
{{{ }}}#!if ns1 != null && ns_end == null && (body_available || pre_available)
{{{#!if ns3_post == null
{{{::}}}}}}#!if ns1 != null && ns_end != null
##======================================= Front-end types
{{{}}}#!if pre1_t != null
{{{#4ec9b0,#6fdbba {{{string}}}}}}#!if pre2_t != null
{{{::}}}{{{#4ec9b0,#6fdbba {{{duration}}}}}}#!if pre_e != null
{{{::}}}{{{#f0f068 {{{enum}}}}}}#!if pre_post != null
##======================================= body begin
{{{}}}#!if (body_available && pre_available)
{{{ }}}#!if body_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if body_v != null
{{{#a9a9b0,#a1a1a2 {{{}}}}}}#!if body_gv != null
{{{#ffa3d2 {{{}}}}}}#!if body_mv != null
{{{#ffffff {{{}}}}}}#!if body_f != null
{{{#f87a7a {{{to_string}}}}}}#!if body_mf != null
{{{#f0a962 {{{}}}}}}#!if body_static_mv != null
{{{#ffffff '''{{{}}}'''}}}#!if body_static_mf != null
{{{#f0a962 '''{{{}}}'''}}}#!if body_number != null
{{{#b5cea8 {{{}}}}}}#!if body_string != null
{{{#c8865e {{{}}}}}}#!if body_post != null
{{{}}}#!if body_tmpopen != null
{{{<}}}#!if body_bopen != null
##======================================= body end
##======================================= arguments begin
{{{(}}}#!if arg1_pre_available = (arg1_concept != null || arg1_kw != null || arg1_t_kw != null || arg1_t != null)
#!if arg2_pre_available = (arg2_concept != null || arg2_kw != null || arg2_t_kw != null || arg2_t != null)
#!if arg3_pre_available = (arg3_concept != null || arg3_kw != null || arg3_t_kw != null || arg3_t != null)
#!if arg4_pre_available = (arg4_concept != null || arg4_kw != null || arg4_t_kw != null || arg4_t != null)
#!if arg1_concept != null
##======================================= argument 1
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if arg1_concept_tparam1 != null
{{{<}}}{{{#4ec9b0,#6fdbba {{{}}}}}}{{{#!if arg1_concept_tparam2 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{#!if arg1_concept_tparam3 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{>}}}}}}{{{ }}}#!if arg1_kw != null
'''{{{#569cd6 {{{const}}}}}}'''#!if arg1_t_kw!=null
{{{#!if arg1_kw != null
{{{ }}}}}}'''{{{#CornFlowerBlue {{{int}}}}}}'''#!if (arg1_t != null) && (arg1_kw != null || arg1_t_kw != null)
{{{ }}}#!if arg1_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if arg1_t != null
{{{#4ec9b0,#6fdbba {{{}}}}}}#!if arg1_t_post!=null
{{{}}}#!if arg1_param != null
{{{#!if !arg1_pre_available
{{{#bcdce6 {{{value}}}}}}}}}{{{#!if arg1_pre_available
{{{#bcdce6 {{{ value}}}}}}}}}#!if (arg1_pre_available || arg1_param != null) && (arg2_pre_available || arg2_param != null)
{{{, }}}#!if arg2_concept!=null
##======================================= argument 2
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if arg2_concept_params != null
{{{<}}}{{{#4ec9b0,#6fdbba {{{}}}}}}{{{#!if ar2_concept_tparam2 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{#!if arg2_concept_tparam3 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{>}}}}}}{{{ }}}#!if arg2_kw != null
'''{{{#569cd6 {{{const}}}}}}'''#!if arg2_t_kw!=null
{{{#!if arg2_kw != null
{{{ }}}}}}'''{{{#CornFlowerBlue {{{int}}}}}}'''#!if (arg2_t != null) && (arg2_kw != null || arg2_t_kw != null)
{{{ }}}#!if arg2_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if arg2_t != null
{{{#4ec9b0,#6fdbba {{{}}}}}}#!if arg2_t_post != null
{{{}}}#!if arg2_param != null
{{{#!if !arg2_pre_available
{{{#bcdce6 {{{}}}}}}}}}{{{#!if arg2_pre_available
{{{#bcdce6 {{{ }}}}}}}}}#!if (arg2_pre_available || arg2_param != null) && (arg3_pre_available || arg3_param != null)
{{{, }}}#!if arg3_concept!=null
##======================================= argument 3
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if arg3_concept_params != null
{{{<}}}{{{#4ec9b0,#6fdbba {{{}}}}}}{{{#!if arg3_concept_tparam2 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{#!if arg3_concept_tparam3 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{>}}}}}}{{{ }}}#!if arg3_kw != null
'''{{{#569cd6 {{{const}}}}}}'''#!if arg3_t_kw!=null
{{{#!if arg3_kw != null
{{{ }}}}}}'''{{{#CornFlowerBlue {{{int}}}}}}'''#!if (arg3_t != null) && (arg3_kw != null || arg3_t_kw != null)
{{{ }}}#!if arg3_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if arg3_t!=null
{{{#4ec9b0,#6fdbba {{{}}}}}}#!if arg3_t_post!=null
{{{}}}#!if arg3_param != null
{{{#!if !arg3_pre_available
{{{#bcdce6 {{{}}}}}}}}}{{{#!if arg3_pre_available
{{{#bcdce6 {{{ }}}}}}}}}#!if (arg3_pre_available || arg3_param != null) && (arg4_pre_available || arg4_param != null)
{{{, }}}#!if arg4_concept!=null
##======================================= argument4
'''{{{#4ec9b0,#6fdbba {{{}}}}}}'''{{{#!if arg4_concept_params != null
{{{<}}}{{{#4ec9b0,#6fdbba {{{}}}}}}{{{#!if arg4_concept_tparam2 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{#!if arg4_concept_tparam3 != null
{{{#4ec9b0,#6fdbba {{{, }}}}}}}}}{{{>}}}}}}{{{ }}}#!if arg4_kw != null
{{{#!if arg4_kw != null
{{{ }}}}}}'''{{{#569cd6 {{{const}}}}}}'''#!if arg4_t_kw != null
'''{{{#CornFlowerBlue {{{int}}}}}}'''#!if (arg4_t != null) && (arg4_kw != null || arg4_t_kw != null)
{{{ }}}#!if arg4_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if arg4_t != null
{{{#4ec9b0,#6fdbba {{{}}}}}}#!if arg4_t_post!=null
{{{}}}#!if arg4_param != null
{{{#!if !arg4_pre_available
{{{#bcdce6 {{{}}}}}}}}}{{{#!if arg4_pre_available
{{{#bcdce6 {{{ }}}}}}}}}#!if arg5_param != null
##======================================= argument5, argument6
{{{#bcdce6 {{{, }}}}}}#!if arg6_param != null
{{{#bcdce6 {{{, }}}}}}#!if arg_last_dots != null
{{{, ...}}}#!if body_bopen != null
##======================================= arguments end
##======================================= body end
##======================================= specifiers begin
{{{#!if body_spec1 != null
{{{) }}}}}}{{{#!if body_spec1 == null
{{{)}}}}}}#!if body_spec1 != null
'''{{{#569cd6 {{{const}}}}}}'''#!if body_spec_assign != null
{{{ = }}}'''{{{#569cd6 {{{default}}}}}}'''#!if body_spec1_paren != null
{{{(}}}#!if body_spec1_ref != null
{{{}}}#!if body_spec2 != null
{{{#!if body_spec1 != null && body_spec1_paren == null
{{{ }}}}}}'''{{{#569cd6 {{{noexcept}}}}}}'''#!if body_spec2_paren != null
{{{(}}}#!if body_spec2_label != null
{{{}}}#!if body_spec2_paren != null
{{{)}}}#!if body_spec1_paren != null
##======================================= specifiers end
##======================================= trailing begin
{{{)}}}#!if trailing != null
{{{ }}}#!if trailing_keyword != null
'''{{{#569cd6 {{{decltype}}}}}}'''#!if trailing_bopen != null
{{{(}}}#!if trailing_ns != null
'''{{{#58fafe {{{std}}}}}}'''{{{::}}}#!if trailing_t_kw != null
'''{{{#CornFlowerBlue {{{int}}}}}}'''#!if trailing_content_t1 != null
{{{#4ec9b0,#6fdbba {{{}}}}}}#!if trailing_content_t2 != null
{{{::}}}{{{#4ec9b0,#6fdbba {{{}}}}}}#!if trailing_content_f != null
{{{#f87a7a {{{}}}}}}#!if trailing_label != null
{{{}}}#!if trailing_bopen != null
{{{)}}}#!if label_last != null
##======================================= trailing end
{{{}}}#!if body_tmpopen != null
##======================================= footer
{{{>}}}#!if last != null
{{{;}}}#!if version != null
^^{{{#a3ff84 C++}}}^^
#!if large_version != null
^^{{{+1 {{{#a3ff84 C++}}}}}}^^||<width=10%><|10>C++11||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| 어떤 정수나 부동 소수점을 스트링 클래스로 변환한다. | |||||||||||
| <bgcolor=#20b580> | |||||||||||
to_string(value)C++11==# 코드 요약 #==
#!syntax cpp
#include <compare>
#include <initializer_list>
namespace std
{
// character traits
template<class CharT> struct char_traits; // freestanding
template<> struct char_traits<char>; // freestanding
template<> struct char_traits<char8_t>; // freestanding
template<> struct char_traits<char16_t>; // freestanding
template<> struct char_traits<char32_t>; // freestanding
template<> struct char_traits<wchar_t>; // freestanding
// basic_string
template<class CharT, class Traits = char_traits<CharT>, class Allocator = allocator<CharT>>
class basic_string;
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const basic_string<CharT, Traits, Allocator>& lhs, const basic_string<CharT, Traits, Allocator>& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(basic_string<CharT, Traits, Allocator>&& lhs, const basic_string<CharT, Traits, Allocator>& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const basic_string<CharT, Traits, Allocator>& lhs, basic_string<CharT, Traits, Allocator>&& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(basic_string<CharT, Traits, Allocator>&& lhs, basic_string<CharT, Traits, Allocator>&& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const CharT* lhs, onst basic_string<CharT, Traits, Allocator>& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const CharT* lhs, basic_string<CharT, Traits, Allocator>&& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(CharT lhs, const basic_string<CharT, Traits, Allocator>& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(CharT lhs, basic_string<CharT, Traits, Allocator>&& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const basic_string<CharT, Traits, Allocator>& lhs,
const CharT* rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(basic_string<CharT, Traits, Allocator>&& lhs, const CharT* rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const basic_string<CharT, Traits, Allocator>& lhs, CharT rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(basic_string<CharT, Traits, Allocator>&& lhs, CharT rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(const basic_string<CharT, Traits, Allocator>& lhs, type_identity_t<basic_string_view<CharT, Traits>> rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(basic_string<CharT, Traits, Allocator>&& lhs, type_identity_t<basic_string_view<CharT, Traits>> rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(type_identity_t<basic_string_view<CharT, Traits>> lhs, const basic_string<CharT, Traits, Allocator>& rhs);
template<class CharT, class Traits, class Allocator>
constexpr basic_string<CharT, Traits, Allocator>
operator+(type_identity_t<basic_string_view<CharT, Traits>> lhs, basic_string<CharT, Traits, Allocator>&& rhs);
template<class CharT, class Traits, class Allocator>
constexpr bool
operator==(const basic_string<CharT, Traits, Allocator>& lhs, const basic_string<CharT, Traits, Allocator>& rhs) noexcept;
template<class CharT, class Traits, class Allocator>
constexpr bool operator==(const basic_string<CharT, Traits, Allocator>& lhs, const CharT* rhs);
template<class CharT, class Traits, class Allocator>
constexpr /* see description */ operator<=>(const basic_string<CharT, raits, Allocator>& lhs,
const basic_string<CharT, Traits, Allocator>& rhs) noexcept;
template<class CharT, class Traits, class Allocator>
constexpr /* see description */ operator<=>(const basic_string<CharT, Traits, Allocator>& lhs, const CharT* rhs);
// swap
template<class CharT, class Traits, class Allocator>
constexpr void swap(basic_string<CharT, Traits, Allocator>& lhs, basic_string<CharT, Traits, Allocator>& rhs) noexcept(noexcept(lhs.swap(rhs)));
// inserters and extractors
template<class CharT, class Traits, class Allocator>
basic_istream<CharT, Traits>&
operator>>(basic_istream<CharT, Traits>& is, basic_string<CharT, Traits, Allocator>& str);
template<class CharT, class Traits, class Allocator>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const basic_string<CharT, Traits, Allocator>& str);
template<class CharT, class Traits, class Allocator>
basic_istream<CharT, Traits>&
getline(basic_istream<CharT, Traits>& is, basic_string<CharT, Traits, Allocator>& str, CharT delim);
template<class CharT, class Traits, class Allocator>
basic_istream<CharT, Traits>&
getline(basic_istream<CharT, Traits>&& is, basic_string<CharT, Traits, Allocator>& str, CharT delim);
template<class CharT, class Traits, class Allocator>
basic_istream<CharT, Traits>&
getline(basic_istream<CharT, Traits>& is, basic_string<CharT, Traits, Allocator>& str);
template<class CharT, class Traits, class Allocator>
basic_istream<CharT, Traits>&
getline(basic_istream<CharT, Traits>&& is, basic_string<CharT, Traits, Allocator>& str);
// erasure
template<class CharT, class Traits, class Allocator, class U = CharT>
constexpr typename basic_string<CharT, Traits, Allocator>::size_type
erase(basic_string<CharT, Traits, Allocator>& c, const U& value);
template<class CharT, class Traits, class Allocator, class Pred>
constexpr typename basic_string<CharT, Traits, Allocator>::size_type
erase_if(basic_string<CharT, Traits, Allocator>& c, Pred pred);
// basic_string typedef-names
using string = basic_string<char>;
using u8string = basic_string<char8_t>;
using u16string = basic_string<char16_t>;
using u32string = basic_string<char32_t>;
using wstring = basic_string<wchar_t>;
// numeric conversions
int stoi(const string& str, size_t* idx = nullptr, int base = 10);
long stol(const string& str, size_t* idx = nullptr, int base = 10);
unsigned long stoul(const string& str, size_t* idx = nullptr, int base = 10);
long long stoll(const string& str, size_t* idx = nullptr, int base = 10);
unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
float stof(const string& str, size_t* idx = nullptr);
double stod(const string& str, size_t* idx = nullptr);
long double stold(const string& str, size_t* idx = nullptr);
string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);
int stoi(const wstring& str, size_t* idx = nullptr, int base = 10);
long stol(const wstring& str, size_t* idx = nullptr, int base = 10);
unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10);
long long stoll(const wstring& str, size_t* idx = nullptr, int base = 10);
unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
float stof(const wstring& str, size_t* idx = nullptr);
double stod(const wstring& str, size_t* idx = nullptr);
long double stold(const wstring& str, size_t* idx = nullptr);
wstring to_wstring(int val);
wstring to_wstring(unsigned val);
wstring to_wstring(long val);
wstring to_wstring(unsigned long val);
wstring to_wstring(long long val);
wstring to_wstring(unsigned long long val);
wstring to_wstring(float val);
wstring to_wstring(double val);
wstring to_wstring(long double val);
// hash support
template<class T> struct hash;
template<class A> struct hash<basic_string<char, char_traits<char>, A>>;
template<class A> struct hash<basic_string<char8_t, char_traits<char8_t>, A>>;
template<class A> struct hash<basic_string<char16_t, char_traits<char16_t>, A>>;
template<class A> struct hash<basic_string<char32_t, char_traits<char32_t>, A>>;
template<class A> struct hash<basic_string<wchar_t, char_traits<wchar_t>, A>>;
namespace pmr
{
template<class CharT, class Traits = char_traits<CharT>>
using basic_string = std::basic_string<CharT, Traits, polymorphic_allocator<CharT>>;
using string = basic_string<char>;
using u8string = basic_string<char8_t>;
using u16string = basic_string<char16_t>;
using u32string = basic_string<char32_t>;
using wstring = basic_string<wchar_t>;
}
inline namespace literals
{
inline namespace string_literals
{
// suffix for basic_string literals
constexpr string operator""s(const char* str, size_t len);
constexpr u8string operator""s(const char8_t* str, size_t len);
constexpr u16string operator""s(const char16_t* str, size_t len);
constexpr u32string operator""s(const char32_t* str, size_t len);
constexpr wstring operator""s(const wchar_t* str, size_t len);
}
}
template<class CharT, class Traits = char_traits<CharT>, class Allocator = allocator<CharT>>
class basic_string {
public:
// types
using traits_type = Traits;
using value_type = CharT;
using allocator_type = Allocator;
using size_type = typename allocator_traits<Allocator>::size_type;
using difference_type = typename allocator_traits<Allocator>::difference_type;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
using reference = value_type&;
using const_reference = const value_type&;
using iterator = /* implementation-defined */;
using const_iterator = /* implementation-defined */;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
static constexpr size_type npos = size_type(-1);
// construct/copy/destroy
constexpr basic_string() noexcept(noexcept(Allocator()))
: basic_string(Allocator()) { }
constexpr explicit basic_string(const Allocator& a) noexcept;
constexpr basic_string(const basic_string& str);
constexpr basic_string(basic_string&& str) noexcept;
constexpr basic_string(const basic_string& str, size_type pos,
const Allocator& a = Allocator());
constexpr basic_string(const basic_string& str, size_type pos, size_type n,
const Allocator& a = Allocator());
constexpr basic_string(basic_string&& str, size_type pos,
const Allocator& a = Allocator());
constexpr basic_string(basic_string&& str, size_type pos, size_type n,
const Allocator& a = Allocator());
template<class T>
constexpr basic_string(const T& t, size_type pos, size_type n,
const Allocator& a = Allocator());
template<class T>
constexpr explicit basic_string(const T& t, const Allocator& a = Allocator());
constexpr basic_string(const CharT* s, size_type n, const Allocator& a = Allocator());
constexpr basic_string(const CharT* s, const Allocator& a = Allocator());
basic_string(nullptr_t) = delete;
constexpr basic_string(size_type n, CharT c, const Allocator& a = Allocator());
template<class InputIt>
constexpr basic_string(InputIt begin, InputIt end,
const Allocator& a = Allocator());
template<container-compatible-range<CharT> R>
constexpr basic_string(from_range_t, R&& rg, const Allocator& a = Allocator());
constexpr basic_string(initializer_list<CharT>, const Allocator& = Allocator());
constexpr basic_string(const basic_string&, const Allocator&);
constexpr basic_string(basic_string&&, const Allocator&);
constexpr ~basic_string();
constexpr basic_string& operator=(const basic_string& str);
constexpr basic_string& operator=(basic_string&& str)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
allocator_traits<Allocator>::is_always_equal::value);
template<class T>
constexpr basic_string& operator=(const T& t);
constexpr basic_string& operator=(const CharT* s);
basic_string& operator=(nullptr_t) = delete;
constexpr basic_string& operator=(CharT c);
constexpr basic_string& operator=(initializer_list<CharT>);
// iterators
constexpr iterator begin() noexcept;
constexpr const_iterator begin() const noexcept;
constexpr iterator end() noexcept;
constexpr const_iterator end() const noexcept;
constexpr reverse_iterator rbegin() noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr reverse_iterator rend() noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr void resize(size_type n, CharT c);
constexpr void resize(size_type n);
template<class Operation>
constexpr void resize_and_overwrite(size_type n, Operation op);
constexpr size_type capacity() const noexcept;
constexpr void reserve(size_type res_arg);
constexpr void shrink_to_fit();
constexpr void clear() noexcept;
constexpr bool empty() const noexcept;
// element access
constexpr const_reference operator[](size_type pos) const;
constexpr reference operator[](size_type pos);
constexpr const_reference at(size_type n) const;
constexpr reference at(size_type n);
constexpr const CharT& front() const;
constexpr CharT& front();
constexpr const CharT& back() const;
constexpr CharT& back();
// modifiers
constexpr basic_string& operator+=(const basic_string& str);
template<class T>
constexpr basic_string& operator+=(const T& t);
constexpr basic_string& operator+=(const CharT* s);
constexpr basic_string& operator+=(CharT c);
constexpr basic_string& operator+=(initializer_list<CharT>);
constexpr basic_string& append(const basic_string& str);
constexpr basic_string& append(const basic_string& str, size_type pos,
size_type n = npos);
template<class T>
constexpr basic_string& append(const T& t);
template<class T>
constexpr basic_string& append(const T& t, size_type pos, size_type n = npos);
constexpr basic_string& append(const CharT* s, size_type n);
constexpr basic_string& append(const CharT* s);
constexpr basic_string& append(size_type n, CharT c);
template<class InputIt>
constexpr basic_string& append(InputIt first, InputIt last);
template<container-compatible-range<CharT> R>
constexpr basic_string& append_range(R&& rg);
constexpr basic_string& append(initializer_list<CharT>);
constexpr void push_back(CharT c);
constexpr basic_string& assign(const basic_string& str);
constexpr basic_string& assign(basic_string&& str)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
allocator_traits<Allocator>::is_always_equal::value);
constexpr basic_string& assign(const basic_string& str, size_type pos,
size_type n = npos);
template<class T>
constexpr basic_string& assign(const T& t);
template<class T>
constexpr basic_string& assign(const T& t, size_type pos, size_type n = npos);
constexpr basic_string& assign(const CharT* s, size_type n);
constexpr basic_string& assign(const CharT* s);
constexpr basic_string& assign(size_type n, CharT c);
template<class InputIt>
constexpr basic_string& assign(InputIt first, InputIt last);
template<container-compatible-range<CharT> R>
constexpr basic_string& assign_range(R&& rg);
constexpr basic_string& assign(initializer_list<CharT>);
constexpr basic_string& insert(size_type pos, const basic_string& str);
constexpr basic_string& insert(size_type pos1, const basic_string& str,
size_type pos2, size_type n = npos);
template<class T>
constexpr basic_string& insert(size_type pos, const T& t);
template<class T>
constexpr basic_string& insert(size_type pos1, const T& t,
size_type pos2, size_type n = npos);
constexpr basic_string& insert(size_type pos, const CharT* s, size_type n);
constexpr basic_string& insert(size_type pos, const CharT* s);
constexpr basic_string& insert(size_type pos, size_type n, CharT c);
constexpr iterator insert(const_iterator p, CharT c);
constexpr iterator insert(const_iterator p, size_type n, CharT c);
template<class InputIt>
constexpr iterator insert(const_iterator p, InputIt first, InputIt last);
template<container-compatible-range<CharT> R>
constexpr iterator insert_range(const_iterator p, R&& rg);
constexpr iterator insert(const_iterator p, initializer_list<CharT>);
constexpr basic_string& erase(size_type pos = 0, size_type n = npos);
constexpr iterator erase(const_iterator p);
constexpr iterator erase(const_iterator first, const_iterator last);
constexpr void pop_back();
constexpr basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
constexpr basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2 = npos);
template<class T>
constexpr basic_string& replace(size_type pos1, size_type n1, const T& t);
template<class T>
constexpr basic_string& replace(size_type pos1, size_type n1, const T& t,
size_type pos2, size_type n2 = npos);
constexpr basic_string& replace(size_type pos, size_type n1, const CharT* s,
size_type n2);
constexpr basic_string& replace(size_type pos, size_type n1, const CharT* s);
constexpr basic_string& replace(size_type pos, size_type n1, size_type n2, CharT c);
constexpr basic_string& replace(const_iterator i1, const_iterator i2,
const basic_string& str);
template<class T>
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const T& t);
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s,
size_type n);
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s);
constexpr basic_string& replace(const_iterator i1, const_iterator i2, size_type n,
CharT c);
template<class InputIt>
constexpr basic_string& replace(const_iterator i1, const_iterator i2,
InputIt j1, InputIt j2);
template<container-compatible-range<CharT> R>
constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2,
R&& rg);
constexpr basic_string& replace(const_iterator, const_iterator,
initializer_list<CharT>);
constexpr size_type copy(CharT* s, size_type n, size_type pos = 0) const;
constexpr void swap(basic_string& str)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
// string operations
constexpr const CharT* c_str() const noexcept;
constexpr const CharT* data() const noexcept;
constexpr CharT* data() noexcept;
constexpr operator basic_string_view<CharT, Traits>() const noexcept;
constexpr allocator_type get_allocator() const noexcept;
template<class T>
constexpr size_type find(const T& t, size_type pos = 0) const noexcept(/* see description */);
constexpr size_type find(const basic_string& str, size_type pos = 0) const noexcept;
constexpr size_type find(const CharT* s, size_type pos, size_type n) const;
constexpr size_type find(const CharT* s, size_type pos = 0) const;
constexpr size_type find(CharT c, size_type pos = 0) const noexcept;
template<class T>
constexpr size_type rfind(const T& t, size_type pos = npos) const noexcept(/* see description */);
constexpr size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
constexpr size_type rfind(const CharT* s, size_type pos, size_type n) const;
constexpr size_type rfind(const CharT* s, size_type pos = npos) const;
constexpr size_type rfind(CharT c, size_type pos = npos) const noexcept;
template<class T>
constexpr size_type find_first_of(const T& t, size_type pos = 0) const noexcept(/* see description */);
constexpr size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(const CharT* s, size_type pos, size_type n) const;
constexpr size_type find_first_of(const CharT* s, size_type pos = 0) const;
constexpr size_type find_first_of(CharT c, size_type pos = 0) const noexcept;
template<class T>
constexpr size_type find_last_of(const T& t, size_type pos = npos) const noexcept(/* see description */);
constexpr size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(const CharT* s, size_type pos, size_type n) const;
constexpr size_type find_last_of(const CharT* s, size_type pos = npos) const;
constexpr size_type find_last_of(CharT c, size_type pos = npos) const noexcept;
template<class T>
constexpr size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(/* see description */);
constexpr size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(const CharT* s, size_type pos, size_type n) const;
constexpr size_type find_first_not_of(const CharT* s, size_type pos = 0) const;
constexpr size_type find_first_not_of(CharT c, size_type pos = 0) const noexcept;
template<class T>
constexpr size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(/* see description */);
constexpr size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(const CharT* s, size_type pos, size_type n) const;
constexpr size_type find_last_not_of(const CharT* s, size_type pos = npos) const;
constexpr size_type find_last_not_of(CharT c, size_type pos = npos) const noexcept;
constexpr basic_string substr(size_type pos = 0, size_type n = npos) const &;
constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
template<class T>
constexpr int compare(const T& t) const noexcept(/* see description */);
template<class T>
constexpr int compare(size_type pos1, size_type n1, const T& t) const;
template<class T>
constexpr int compare(size_type pos1, size_type n1, const T& t,
size_type pos2, size_type n2 = npos) const;
constexpr int compare(const basic_string& str) const noexcept;
constexpr int compare(size_type pos1, size_type n1, const basic_string& str) const;
constexpr int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2 = npos) const;
constexpr int compare(const CharT* s) const;
constexpr int compare(size_type pos1, size_type n1, const CharT* s) const;
constexpr int compare(size_type pos1, size_type n1, const CharT* s, size_type n2) const;
constexpr bool starts_with(basic_string_view<CharT, Traits> x) const noexcept;
constexpr bool starts_with(CharT x) const noexcept;
constexpr bool starts_with(const CharT* x) const;
constexpr bool ends_with(basic_string_view<CharT, Traits> x) const noexcept;
constexpr bool ends_with(CharT x) const noexcept;
constexpr bool ends_with(const CharT* x) const;
constexpr bool contains(basic_string_view<CharT, Traits> x) const noexcept;
constexpr bool contains(CharT x) const noexcept;
constexpr bool contains(const CharT* x) const;
};
template<class InputIt, class Allocator = allocator<typename iterator_traits<InputIt>::value_type>>
basic_string(InputIt, InputIt, Allocator = Allocator())
-> basic_string<typename iterator_traits<InputIt>::value_type, char_traits<typename iterator_traits<InputIt>::value_type>, Allocator>;
template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>>
basic_string(from_range_t, R&&, Allocator = Allocator())
-> basic_string<ranges::range_value_t<R>, char_traits<ranges::range_value_t<R>>, Allocator>;
template<class CharT, class Traits, class Allocator = allocator<CharT>>
explicit basic_string(basic_string_view<CharT, Traits>, const Allocator& = Allocator())
-> basic_string<CharT, Traits, Allocator>;
template<class CharT, class Traits, class Allocator = allocator<CharT>>
basic_string(basic_string_view<CharT, Traits>, typename /* see description */::size_type, typename /* see description */::size_type,
const Allocator& = Allocator())
-> basic_string<CharT, Traits, Allocator>;
}
4. 둘러보기
||<:><-12><width=90%><tablewidth=100%><tablebordercolor=#20b580><rowbgcolor=#090f0a,#050b09><rowcolor=#d7d7d7,#a1a1a1>C++||||
}}}
}}}||
}}}||
| C언어와의 차이점 | 학습 자료 | 평가 | |||||||||||||
| <bgcolor=#20b580> | |||||||||||||||
| <rowcolor=#090912,#bebebf>C++ 문법 | |||||||||||||||
| <bgcolor=#ffffff> | |||||||||||||||
main | 헤더 | 모듈 | |||||||||||||
| 함수 | 구조체 | 이름공간 | |||||||||||||
| 한정자 | 참조자 | 포인터 | |||||||||||||
| 클래스 | 값 범주론 | 특성 | |||||||||||||
auto | using | decltype | |||||||||||||
| 상수 표현식 | 람다 표현식 | 객체 이름 검색 | |||||||||||||
| 템플릿 | 템플릿 제약조건 | 메타 프로그래밍 | |||||||||||||
| <bgcolor=#20b580> | |||||||||||||||
| <rowcolor=#090912,#bebebf>C++ 버전 | |||||||||||||||
| <bgcolor=#ffffff> | |||||||||||||||
| C++26 | C++23 | C++20 | |||||||||||||
| C++17 | C++14 | C++11 | |||||||||||||
| C++03 | C++98 | C with Classes | |||||||||||||
| <bgcolor=#20b580> | |||||||||||||||
| <rowcolor=#090912,#bebebf>C++ 표준 라이브러리 | |||||||||||||||
| <rowcolor=#090912,#bebebf>문서가 있는 모듈 목록 | |||||||||||||||
| <bgcolor=#ffffff> | |||||||||||||||
#개요 | C++11 #개요 | <unordered_map>C++11 #개요 | |||||||||||||
C++20 #개요 | #개요 | #개요 | |||||||||||||
C++11 #개요 | C++11 #개요 | C++17 #개요 | |||||||||||||
#개요 | <string_view>C++17 #개요 | C++20 #개요 | |||||||||||||
C++11 #개요 | C++11 #개요 | C++11 #개요 | |||||||||||||
C++20 #개요 | C++23 #개요 | ||||||||||||||
| <bgcolor=#20b580> | |||||||||||||||
| <rowcolor=#090912,#bebebf>예제 목록 | |||||||||||||||
| <bgcolor=#ffffff> | |||||||||||||||
| {{{#!wiki style=""text-align: center, margin: 0 -10px" {{{#!folding [ 펼치기 · 접기 ] | 임계 영역과 경쟁 상태std::mutex | 개선된 스레드 클래스std::jthread | 동시성 자료 구조 1 스레드 안전한 큐 구현 | 동시성 자료 구조 2 스레드 안전한 집합 구현 | |||||||||||
메모리 장벽std::atomic_thread_fence | 스레드 상태 동기화 1 스레드 대기와 기상 | 원자적 메모리 수정std::compare_exchange_strong | 스레드 상태 동기화 2 스핀 락 구현 | ||||||||||||
| 함수 템플릿 일반화 프로그래밍 | 전이 참조 완벽한 매개변수 전달 | 튜플 구현 가변 클래스 템플릿 | 직렬화 함수 구현 템플릿 매개변수 묶음 | ||||||||||||
| SFINAE 1 멤버 함수 검사 | SFINAE 2 자료형 태그 검사 | SFINAE 3 메타 데이터 | SFINAE 4 자료형 트레잇 | ||||||||||||
| 제약조건 1 개념 (Concept) | 제약조건 2 상속 여부 검사 | 제약조건 3 클래스 명세 파헤치기 | 제약조건 4 튜플로 함자 실행하기 | ||||||||||||
| 메타 프로그래밍 1 특수화 여부 검사 | 메타 프로그래밍 2 컴파일 시점 문자열 | 메타 프로그래밍 3 자료형 리스트 | 메타 프로그래밍 4 안전한 union | ||||||||||||
}}}||
| <bgcolor=#20b580> | |||||||||||||||
| <rowcolor=#090912,#bebebf>외부 링크 | |||||||||||||||
| <bgcolor=#ffffff> | |||||||||||||||
| {{{#!wiki style=""text-align: center, margin: 0 -10px" | |||||||||||||||
| <bgcolor=#20b580> | |||||||||||
| <rowcolor=#090912,#bebebf>C++ |
[이하] 스트링 클래스