{"id":175691,"date":"2013-04-11T01:02:03","date_gmt":"2013-04-10T21:02:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=175691"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=175691","title":{"rendered":"<span class=\"post_title\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u0431 std::string<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 std::string \u0432 libstdc++. \u041d\u0435 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430, \u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u0411\u043b\u0430\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043c\u0443 \u0442\u0438\u043f\u0443 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0437\u0438\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0433\u043b\u044f\u0434\u044b\u0432\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0434\u0438\u043e\u043c\u0443 \u00ab\u0442\u0440\u0430\u0441\u0441\u0435\u0440\u00bb \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u0443\u044e \u0432 \u00abC++ Templates: The Complete Guide\u00bb. \u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c <s>\u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435<\/s> \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, std::string \u044d\u0442\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0434\u043b\u044f <code>std::basic_string&lt;char&gt;<\/code> \u0438 \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>std::basic_string&lt;X&gt;<\/code>. \u0412 X \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. <br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 g++ \u0434\u043b\u044f <code>std::string a(\u00abentrails\u00bb); <\/code>\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <br \/>  <code>std::cout &lt;&lt; reinterpret_cast&lt;char*&gt;(*((void**)(&a))); <\/code><br \/>  \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0422.\u0435. std::string \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 char.<br \/>  \u0412\u043e\u0431\u0449\u0435\u043c, \u044d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 <s>\u0448\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435<\/s> <a name=\"habracut\"><\/a> <\/p>\n<h5>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h5>\n<p>std::string \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">  typedef basic_string&lt;char&gt;    string; <\/code><\/pre>\n<p><code> basic_string&lt;char&gt;<\/code>, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u043c \u0434\u043b\u044f:  <\/p>\n<pre><code class=\"cpp\">template&lt;typename _CharT, typename _Traits = char_traits&lt;_CharT&gt;, typename _Alloc = allocator&lt;_CharT&gt; &gt;  class basic_string;  <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 basic_string \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 c++\/bits\/basic_string.h c++\/bits\/basic_string.tcc.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename _CharT, typename _Traits, typename _Alloc&gt; class basic_string{ public:      static const size_type    npos = static_cast&lt;size_type&gt;(-1); private:     struct _Rep_base{         size_type            _M_length;  \/\/\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 size_t         size_type            _M_capacity;         _Atomic_word   _M_refcount;     };     struct Rep:_Rep_base{         static const size_type         _S_max_size; \/\/(((npos - sizeof(_Rep_base))\/sizeof(_CharT)) - 1) \/ 4         static const _CharT            _S_terminal;   \/\/\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u043e\u0439 _CharT()         static size_type                    _S_empty_rep_storage[]; \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043d\u0443\u043b\u044f\u043c\u0438 \u0434\u043b\u0438\u043d\u043e\u0439 (sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) \/sizeof(size_type)     };      struct _Alloc_hider : _Alloc{             _Alloc_hider(_CharT* __dat, const _Alloc& __a) : _Alloc(__a), _M_p(__dat) { }         _CharT* _M_p; \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.        };         mutable _Alloc_hider      _M_dataplus; \/\/\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430 string }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>, \u0447\u0442\u043e \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0440\u0430\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c. \u041f\u0440\u0438\u0447\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435, _M_p \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 _CharT. <br \/>  \u0422\u0430\u043a\u0430\u044f \u0445\u0438\u0442\u0440\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 std::string \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 allocate() \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0430, \u0437\u0430\u0442\u0435\u043c construct(). Allocate() \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e malloc() \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 construct() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 placement new \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 destruct() \u0438 deallocate() \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430. <br \/>  \u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 basic_string.h, \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f std::string \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438. \u0422\u043e\u0433\u0434\u0430 gdb \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 std::string.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b9f\/4a1\/f96\/b9f4a1f96ea341f0c42a31b649c43ea7.png\"\/><br \/>  \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u0430\u043c\u043e\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0437\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e _M_refcount \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 4 \u0431\u0430\u0439\u0442\u0430, \u043d\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e 8(\u0434\u043b\u044f x86-64). \u0421\u0442\u0440\u043e\u043a\u0438 1) \u0438 2) \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438. X \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0442\u0440\u0430\u0441\u0441\u0435\u0440\u0430, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0447\u043b\u0435\u043d\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 std::string. <br \/>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b npos \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f. \u041d\u043e\u2026 \u044d\u0442\u043e \u043d\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 std::string \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 std::string::size_type. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 \u0447\u0435\u0442\u0432\u0435\u0440\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u043e\u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0447\u043b\u0435\u043d\u043e\u043c:<br \/>  _S_max_size;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0446\u0438\u0442\u0430\u0442\u0430 \u0438\u0437 c++\/bits\/basic_string.tcc<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;     const typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type     basic_string&lt;_CharT, _Traits, _Alloc&gt;::     _Rep::_S_max_size = (((npos - sizeof(_Rep_base))\/sizeof(_CharT)) - 1) \/ 4; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044c \u2014 \u043c\u043d\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0442\u0430\u043a \u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<br \/>  _S_terminal \u2014 \u0441\u0438\u043c\u0432\u043e\u043b \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u043d \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. <\/p>\n<h5>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a<\/h5>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0441\u044b\u043b\u043e\u043a. \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<br \/>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f _S_empty_rep_storage \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0431\u043b\u043e\u043a\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435.<br \/>  \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 _M_refcount.<br \/>  _M_refcount:  <\/p>\n<ul>\n<li>-1: \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0441\u044b\u043b\u043a\u0443, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e;  <\/li>\n<li>0: \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c;  <\/li>\n<li>n&gt;0: \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 n+1 \u0441\u0442\u0440\u043e\u043a \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c. (\u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438)  <\/li>\n<\/ul>\n<p>  \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e _M_refcount \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 -1 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0442\u044c \u00ab\u043b\u0435\u043d\u0438\u0432\u043e\u0435\u00bb \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 std::string \u043d\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u043a\u0440\u043e\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 _GLIBCXX_FULLY_DYNAMIC_STRING \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043d\u043e \u0432 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043e\u043d\u043e \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0433\u043b\u0443\u0431\u0436\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u044f \u043d\u0435 \u0441\u0442\u0430\u043b. \u0412 \u0446\u0435\u043b\u043e\u043c \u044d\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u043a\u0443\u0442\u043e\u0440\u0430 \u043a \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u044e\u0442 \u043e \u0441\u0435\u0431\u0435 \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. Helgrind \u0438 drd \u0432\u044b\u0434\u0430\u044e\u0442 \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443.<\/p>\n<h5>\u0422\u0440\u0430\u0441\u0441\u0435\u0440<\/h5>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 std::string \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u0432\u043e\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0410 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u043d\u0430\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0434\u0438\u043e\u043c\u0443 \u00ab\u0442\u0440\u0430\u0441\u0441\u0435\u0440\u00bb. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u0437\u0430\u043a\u043b\u044e\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u0434 \u043d\u0438\u043c. \u0418\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0446\u0438\u0439 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0438\u043b\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c. \u041d\u0443 \u0430 std::string \u0431\u043e\u043b\u0435\u0435 \u0438\u043b\u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u044b. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b, \u043c\u0435\u0442\u043e\u0434\u044b, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b \u0432 \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u043e\u0442 \u043d\u0430\u0448   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0442\u0440\u0430\u0441\u0441\u0435\u0440 X<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct X{         char v; \/\/value          X():v(){ X::c[ctor]++; };         X(char x):v(x){ X::c[ctor]++; };         X(X const& x):v(x.v) { X::c[copy]++; };         ~X(){ X::c[dtor]++; };          X& operator=(X const& x) { X::c[assgn]++; v=x.v; return *this; };         X& operator=(char x) { X::c[assgn]++; v = x;   return *this; };         X& operator()(char x) { X::c[cast]++; v = x;   return *this; };\/\/ X a = X('c');         operator char() const { X::c[cast]++; return v; };             \/\/ char x = a;         bool operator==( X const & x) const { X::c[eql]++; return v == x.v; };         bool operator==( char x) const { X::c[eql]++; return v == x; };         bool operator&lt;( X const& x) const { X::c[lss]++; return v &lt; x.v; };             bool operator&lt;( int x) const { X::c[lss]++; return v &lt; x; };    \/\/for boost           enum { ctor=0, copy, assgn, dtor, lss, eql, cast, last };             static int c[]; \/\/counters         static ::std::string n[]; \/\/names of the counters         static void show(const ::std::string &title, const ::std::string& end);         static void head(const ::std::string &header); }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 X \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 char v; \u2014 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0414\u0432\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043c\u0435\u043d \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432. \u041f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439, \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439(==,&lt;) \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u043a\/\u043e\u0442 char. \u0412\u0441\u0435\u0433\u043e \u0441\u0435\u043c\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432. \u0414\u0432\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 show \u0438 head \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. Show \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0445. Head \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432.<br \/>  \u0414\u043b\u044f \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0438 \u0442\u0440\u0430\u0441\u0441\u0435\u0440\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043e\u043d \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445:  <\/p>\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>{<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>X a;<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>a = &#8216;1&#8217;;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>X b = a;<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>X c(a);<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>c(&#8216;e&#8217;);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>c = b;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>(c=b)=&#8217;e&#8217;;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>a &lt; b;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>a == b;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>}<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>3<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0438 \u0442\u0440\u0430\u0441\u0441\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">        X::head();         X::show(&quot;{&quot;); {       \/\/single operations         X a;         X::show(&quot;X a;&quot;);         a = '1';         X::show(&quot;a = '1';&quot;);         X b = a;         X::show(&quot;X b = a;&quot;);         X c(a);         X::show(&quot;X c(a);&quot;);         c('e');         X::show(&quot;c('e');&quot;);         c = b;         X::show(&quot;c = b;&quot;);         (c = b) = 'e';         X::show(&quot;(c=b)='e';&quot;);         c &lt; b;         X::show(&quot;a &lt; b;&quot;);         a == b;         X::show(&quot;a == b;&quot;); }         X::show(&quot;}&quot;); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>\u0422.\u043a. \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 _S_terminal. \u0415\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<br \/>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:  <\/p>\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>{<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>X a[10];<\/td>\n<td>10<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>std::copy(ch,ch+10,a);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>10<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>X b[10] = {&#8216;o&#8217;};<\/td>\n<td>10<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>std::copy(a,a+10,b);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>10<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>}<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>20<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 X<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">{         X::show(&quot;{&quot;);         X a[10];         X::show(&quot;X a[10];&quot;);         std::copy(ch,ch+10,a);         X::show(&quot;std::copy(ch,ch+10,a);&quot;);         X b[10] = { 'o' };         X::show(&quot;X b[10] = {'o'};&quot;);         std::copy(a,a+10,b);         X::show(&quot;std::copy(a,a+10,b);&quot;); }         X::show(&quot;}&quot;); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0442\u0440\u043e\u043a\u0430\u043c. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448\u0443 \u0442\u0440\u0430\u0441\u0441\u0438\u0442\u0443\u0435\u043c\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u043a <code>typedef std::basic_string&lt;X&gt; xs;<\/code><br \/>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438.  <\/p>\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>{<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>const xs s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s2(s1);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s3 = s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>}<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">{         X::head();         X::show(&quot;{&quot;);         const xs s1;          X::show(&quot;const xs s1;&quot;);         xs s2(s1);         X::show(&quot;xs s2(s1);&quot;);         xs s3 = s1;          X::show(&quot;xs s3 = s1;&quot;); }         X::show(&quot;}&quot;); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0441\u0430\u043c\u0430 \u0437\u0430 \u0441\u0435\u0431\u044f. \u0421\u043c\u0443\u0442\u0438\u043b\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u0434\u043b\u0438\u043d\u044b(s2) \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 s1. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 s1 \u0438 s2 \u043f\u043e\u0432\u0435\u043b\u0438 \u0441\u0435\u0431\u044f \u0440\u0430\u0437\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0414\u043b\u044f s6 \u043b\u0435\u043d\u0438\u0432\u043e\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0434\u043b\u044f s5 \u2014 \u043d\u0435\u0442. \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0443\u0434\u0438\u0432\u0438\u043b \u2014 \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u0432\u0437\u044f\u043b\u0438\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b.  <\/p>\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>{<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s1((X*)\u00ab1234567890\u00bb);<\/td>\n<td>11<\/td>\n<td>0<\/td>\n<td>11<\/td>\n<td>11<\/td>\n<td>0<\/td>\n<td>11<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s2((X*)\u00ab1234567890\u00bb,7);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s3(10,&#8217;a&#8217;);<\/td>\n<td>1<\/td>\n<td>3<\/td>\n<td>11<\/td>\n<td>4<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s4(s1.begin(), s1.begin()+7);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s5(s2);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s5[0]=&#8217;a&#8217;;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>9<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s6(s1);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>11<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s6[0]=&#8217;a&#8217;;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s7(s1,1,5);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>6<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>xs s8=[]()-&gt;xs{xs a((X*)\u00abololo\u00bb);return a;}();<\/td>\n<td>6<\/td>\n<td>0<\/td>\n<td>6<\/td>\n<td>6<\/td>\n<td>0<\/td>\n<td>6<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f resize \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u0443\u0436\u0435 \u0447\u0435\u043c \u0434\u043b\u044f reserve:  <\/p>\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>int a = s1.size();<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s1.resize(100);<\/td>\n<td>1<\/td>\n<td>3<\/td>\n<td>102<\/td>\n<td>4<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s2.reserve(100);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s1.erase();<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0443\u0442 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<table>\n<tr>\n<th>operation<\/th>\n<th>ctor<\/th>\n<th>copy<\/th>\n<th>assgn<\/th>\n<th>dtor<\/th>\n<th>lss<\/th>\n<th>eql<\/th>\n<th>cast<\/th>\n<th><\/th>\n<\/tr>\n<tr>\n<td>s1.insert(0,s2);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s1.insert(0,s2,2,4);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>5<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s3 = s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s3 == s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s2 != s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s1 &gt; s2;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>equal(s1.begin(),s1.end(),s2.begin());<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>mismatch(s1.begin(),s1.end(),s2.begin());<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>copy(s1.begin(),s1.end(),out_it);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>11<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>std::sort(s1.begin(),s1.end());<\/td>\n<td>0<\/td>\n<td>10<\/td>\n<td>24<\/td>\n<td>10<\/td>\n<td>29<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>std::swap(s1,s2);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s3 = s1 + s2;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>20<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s1 + s2;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>20<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s3 += s1;<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>27<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s3.substr(10);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>16<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s4 = s3.substr(10);<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>16<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>s4 = s3.find(s2);<\/td>\n<td>1<\/td>\n<td>3<\/td>\n<td>2<\/td>\n<td>4<\/td>\n<td>26<\/td>\n<td>8<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>}<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418 \u0438\u0445 \u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">{ \tX::head(); \tX::show(&quot;{&quot;); \txs s1((X*)&quot;1234567890&quot;); \tX::show(&quot;xs s1((X*)\\&quot;1234567890\\&quot;);&quot;); \txs s2((X*)&quot;1234567890&quot;,7); \tX::show(&quot;xs s2((X*)\\&quot;1234567890\\&quot;,7);&quot;); \txs s3(10,'a'); \tX::show(&quot;xs s3(10,'a');&quot;); \txs s4(s1.begin(), s1.begin()+7); \tX::show(&quot;xs s4(s1.begin(), s1.begin()+7);&quot;); \txs s5(s2); \tX::show(&quot;xs s5(s2);&quot;); \ts5[0]='a'; \tX::show(&quot;s5[0]='a';&quot;); \txs s6(s1); \tX::show(&quot;xs s6(s1);&quot;); \ts6[0]='a'; \tX::show(&quot;s6[0]='a';&quot;); \txs s7(s1,1,5); \tX::show(&quot;xs s7(s1,1,5);&quot;); \t#if __cplusplus &gt; 199711L \txs s8 = []()-&gt;xs{xs a((X*)&quot;ololo&quot;);return a;}(); \tX::show(&quot;xs s8=[]()-&gt;xs{xs a((X*)\\&quot;lol\\&quot;);return a;}();&quot;); \t#endif \/\/----------------------------------------------------------------  \tint a = s1.size(); \tX::show(&quot;int a = s1.size();&quot;); \ts1.resize(100); \tX::show(&quot;s1.resize(100);&quot;); \ts2.reserve(100); \tX::show(&quot;s2.reserve(100);&quot;); \ts1.erase(); \tX::show(&quot;s1.erase();&quot;); \ts1.insert(0,s2); \tX::show(&quot;s1.insert(0,s2);&quot;); \ts1.insert(0,s2,2,4); \tX::show(&quot;s1.insert(0,s2,2,4);&quot;);  \/\/----------------------------------------------------------------  \tX::show(&quot;s3 = s1;&quot;); \ts3 == s1;\t \tX::show(&quot;s3 == s1;&quot;); \ts2 != s1; \tX::show(&quot;s2 != s1;&quot;); \ts1 &gt; s2; \tX::show(&quot;s1 &gt; s2;&quot;);          std::equal(s1.begin(),s1.end(),s2.begin());         X::show(&quot;equal(s1.begin(),s1.end(),s2.begin());&quot;);         std::mismatch(s1.begin(),s1.end(),s2.begin());         X::show(&quot;mismatch(s1.begin(),s1.end(),s2.begin());&quot;);                  std::copy(s1.begin(),s1.end(),out_it);         std::cout &lt;&lt; std::endl;          X::show(&quot;copy(s1.begin(),s1.end(),out_it);&quot;);                  std::sort(s1.begin(),s1.end());         X::show(&quot;std::sort(s1.begin(),s1.end());&quot;);         std::swap(s1,s2);         X::show(&quot;std::swap(s1,s2);&quot;);         s3 = s1 + s2;         X::show(&quot;s3 = s1 + s2;&quot;);         s1 + s2;                 X::show(&quot;s1 + s2;&quot;);         s3 += s1;                X::show(&quot;s3 += s1;&quot;);         s3.substr(10);           X::show(&quot;s3.substr(10);&quot;);         s4 = s3.substr(10);              X::show(&quot;s4 = s3.substr(10);&quot;);         s4 = s3.find(s2);         X::show(&quot;s4 = s3.find(s2);&quot;); } \tX::show(&quot;}&quot;); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438? \u041d\u0443 \u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c reserve, \u0430 \u043d\u0435 resize, \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u0432\u043e\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e-\u0442\u043e \u0435\u0449\u0435. \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0434\u0430\u0435\u0442 \u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f g++ 4.7.2, intel 13.0.1, clang 3.2, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e <a href=\"http:\/\/liveworkspace.org\/code\/3G97cB$1\">\u0437\u0434\u0435\u0441\u044c<\/a><br \/>   \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f memcmp \u0432\u043c\u0435\u0441\u0442\u043e <code>operator&gt;()<\/code> \u0432 \u0446\u0438\u043a\u043b\u0435). \u041d\u043e \u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u043c\u0435\u0442\u043e\u0434 \u0442\u0440\u0430\u0441\u0441\u0435\u0440\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0414\u043b\u044f \u0447\u0438\u0441\u0442\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u044d\u0442\u0430 \u043e\u0446\u0435\u043d\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u043e\u0436\u0435.<\/p>\n<p>  \u0412\u043e\u0442, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435.<br \/>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438 \u0431\u044b\u043b\u0438 <br \/>  <a href=\"http:\/\/www.cplusplus.com\/reference\/string\/\">\u044d\u0442\u043e\u0442 \u0440\u0435\u0444\u0435\u0440\u0435\u043d\u0441<\/a>, \u0444\u0430\u0439\u043b\u044b:<br \/>  \/usr\/include\/c++\/4.7.2\/strings<br \/>  \/usr\/include\/c++\/4.7.2\/bits\/stringfwd.h<br \/>  \/usr\/include\/c++\/4.7.2.\/bits\/basic_string.h<br \/>  \/usr\/include\/c++\/4.7.2.\/bits\/basic_string.tcc<br \/>  \u0438 gdb.<\/p>\n<h5>PS.<\/h5>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0442\u0441\u043a\u0440\u0438\u043f\u0442\u0443\u043c\u0430 <s>\u0438 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/s> \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u043d\u0430\u0448 \u0442\u0440\u0430\u0441\u0441\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0437\u0430\u0442\u0440\u0430\u0442 \u043d\u0430 \u0440\u0430\u0437\u0431\u043e\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 boost::spirit. \u041d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 \u0432\u044b\u043b\u043e\u0436\u0435\u043d \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a <a href=\"https:\/\/github.com\/korisk\/tracer\">\u0442\u0440\u0430\u0441\u0441\u0435\u0440\u0430<\/a> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c calc5.cpp \u0438\u0437 boost::spirit.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/175691\/\"> http:\/\/habrahabr.ru\/post\/175691\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 std::string \u0432 libstdc++. \u041d\u0435 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430, \u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u0411\u043b\u0430\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043c\u0443 \u0442\u0438\u043f\u0443 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0437\u0438\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0433\u043b\u044f\u0434\u044b\u0432\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0434\u0438\u043e\u043c\u0443 \u00ab\u0442\u0440\u0430\u0441\u0441\u0435\u0440\u00bb \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u0443\u044e \u0432 \u00abC++ Templates: The Complete Guide\u00bb. \u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c <s>\u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435<\/s> \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, std::string \u044d\u0442\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0434\u043b\u044f <code>std::basic_string&lt;char&gt;<\/code> \u0438 \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>std::basic_string&lt;X&gt;<\/code>. \u0412 X \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. <br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 g++ \u0434\u043b\u044f <code>std::string a(\u00abentrails\u00bb); <\/code>\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <br \/>  <code>std::cout &lt;&lt; reinterpret_cast&lt;char*&gt;(*((void**)(&#038;a))); <\/code><br \/>  \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0422.\u0435. std::string \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 char.<br \/>  \u0412\u043e\u0431\u0449\u0435\u043c, \u044d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 <s>\u0448\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435<\/s> <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-175691","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/175691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=175691"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/175691\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=175691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=175691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=175691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}