[ Web Proxy ]
URL:
Viewing: http://ru.cppreference.com/cpp/string/basic_string [Back]  [Original]

std::basic_string cppreference.com
cppreference.com

std::basic_string

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
 
std::basic_string
-
(C++17)
,
/
( C++20)( C++20)( C++20)( C++20)( C++20)(C++20)
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
 
<tbody> </tbody>
template< class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> > class basic_string;
(1)
namespace pmr { template <class CharT, class Traits = std::char_traits<CharT>> using basic_string = std::basic_string< CharT, Traits, std::pmr::polymorphic_allocator<CharT> >; }
(2) ( C++17)

basic_string char- , . , . Traits - std::char_traits . Traits::char_type CharT ; .

basic_string , basic_string s, &*(s.begin() + n) == &*s.begin() + n n [0s.size()), *(s.begin() + s.size()) CharT() ( ) ( C++11); , , s[0] , ( C++11), ( C++11) CharT.

std::basic_string AllocatorAwareContainer, SequenceContainer ContiguousContainer ( C++17)

- std::basic_string constexpr: std::string .

std::string constexpr, .

( C++20)

:

<string>
std::string std::basic_string<char>
std::wstring std::basic_string<wchar_t>
std::u8string (C++20) std::basic_string<char8_t>
std::u16string (C++11) std::basic_string<char16_t>
std::u32string (C++11) std::basic_string<char32_t>
std::pmr::string (C++17) std::pmr::basic_string<char>
std::pmr::wstring (C++17) std::pmr::basic_string<wchar_t>
std::pmr::u8string (C++20) std::pmr::basic_string<char8_t>
std::pmr::u16string (C++17) std::pmr::basic_string<char16_t>
std::pmr::u32string (C++17) std::pmr::basic_string<char32_t>

CharT
Traits ,
Allocator Allocator,

traits_type Traits
value_type CharT
allocator_type Allocator []
size_type
Allocator::size_type ( C++11)
std::allocator_traits<Allocator>::size_type ( C++11)
[]
difference_type
Allocator::difference_type ( C++11)
std::allocator_traits<Allocator>::difference_type ( C++11)
[]
reference value_type& []
const_reference const value_type& []
pointer
Allocator::pointer ( C++11)
std::allocator_traits<Allocator>::pointer ( C++11)
[]
const_pointer
Allocator::const_pointer ( C++11)
std::allocator_traits<Allocator>::const_pointer ( C++11)
[]
iterator

LegacyRandomAccessIterator LegacyContiguousIterator value_type

( C++20)

LegacyRandomAccessIterator, contiguous_iterator ConstexprIterator value_type

( C++20)
[]
const_iterator

LegacyContiguousIterator const value_type

( C++20)

LegacyRandomAccessIterator, contiguous_iterator ConstexprIterator const value_type

( C++20)
[]
reverse_iterator std::reverse_iterator<iterator>[]
const_reverse_iterator std::reverse_iterator<const_iterator>[]

basic_string
(public -) []
, ,
(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []
(DR*)

(public -) []
(DR*)

(public -) []

(public -) []
C
(public -) []
string_view
(public -) []

(public -) []

(public -) []

(public -) []

(public -) []
,
(public -) []

(public -) []

(public -) []

(public -) []
,
(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []
,
(public -) []
(C++20)
,
(public -) []
(C++23)
,
(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []
, , ,
(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

(public -) []

[static]
.
(public static -) []

,


( ) []
( C++20)( C++20)( C++20)( C++20)( C++20)(C++20)

( ) []
std::swap
( ) []
,
( ) []
/

( ) []
-
( ) []
(C++11)(C++11)(C++11)

() []
(C++11)(C++11)

() []
(C++11)(C++11)(C++11)

() []
(C++11)
string
() []
wstring
() []

std::literals::string_literals
basic_string
() []


( ) []

( C++17)

C++23 , construct destroy std::basic_string, . P1072R10, .

__cpp_lib_string_udls 201304L (C++14)
__cpp_lib_string_contains 202011L (C++23) contains
__cpp_lib_string_resize_and_overwrite 202110L (C++23) resize_and_overwrite
__cpp_lib_containers_ranges 202202L (C++23) - , , no section name

#include <iostream>
#include <string>

int main()
{
    using namespace std::literals;

    //    const char*
    std::string str1 = "";

    //      
    auto str2 = ""s;

    //  
    std::string str3 = str1 + " " + str2;

    //  
    std::cout << str3 << '\n';

    std::string::size_type pos = str3.find(" ");
    str1 = str3.substr(pos + 1); //   
    str2 = str3.substr(0, pos);  //   

    std::cout << str1 << ' ' << str2 << '\n';

    //        operator[]
    std::cout << str1[0] << '\n';
    str1[0] = '';
    std::cout << str1 << '\n';
}

:

 
 


C++:

LWG 530 C++98 basic_string


( ) []

Web Proxy Viewer  |  New URL  |  Original Page