{"id":292412,"date":"2019-07-22T21:00:24","date_gmt":"2019-07-22T21:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=292412"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=292412","title":{"rendered":"\u041b\u0438\u043a\u0431\u0435\u0437 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b (\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 C++, \u043f\u0440\u0438\u043c\u0435\u0440\u044b)"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0421\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u043c <a href=\"https:\/\/habr.com\/ru\/post\/460831\/#comment_20416435\">habr.com\/ru\/post\/460831\/#comment_20416435<\/a> \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0435\u0439\u0441\u044f \u0442\u0430\u043c \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u0438, \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0441\u0435\u0442\u0442\u0435\u0440. \u041d\u0430 StackOverflow \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u043e, \u043d\u043e \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u044f \u043d\u0435 \u043f\u0440\u0438\u043f\u043e\u043c\u043d\u044e.<\/p>\n<p>  \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d, \u0438 \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043f\u0440\u0430\u0432. \u0412\u043e\u0442 \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">\/\/ \u0425\u043e\u0440\u043e\u0448\u043e. struct person {   person(std::string first_name, std::string last_name)     : first_name{std::move(first_name)} \/\/ \u0432\u0435\u0440\u043d\u043e     , last_name{std::move(last_name)} \/\/ std::move \u0437\u0434\u0435\u0441\u044c \u0421\u0423\u0429\u0415\u0421\u0422\u0412\u0415\u041d\u0415\u041d!   {} private:   std::string first_name;   std::string last_name; }; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 (\u043d\u0443 \u043b\u0430\u0434\u043d\u043e, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"cpp\">std::string first{\"abc\"}, last{\"def\"}; person p1{first, last};  \/\/ (1) \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u0440\u043e\u043a person p2{std::move(first), last}; \/\/ !!! \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 person p2{std::move(first), std::move(last)}; \/\/ (3) \u043d\u0435\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f person p3{\"x\", \"y\"}; \/\/ \u043d\u0435\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u043f\u043e const&amp;: \u043e\u043d \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0445\u0443\u0436\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (3):<\/p>\n<pre><code class=\"cpp\">\/\/ \u041f\u043b\u043e\u0445\u043e\u0432\u0430\u0442\u043e. struct person {   person(const std::string&amp; first_name, const std::string&amp; last_name)     : first_name{first_name}     , last_name{last_name}   {} private:   std::string first_name;   std::string last_name; };  std::string first{\"abc\"}, last{\"def\"}; person p1{first, last}; \/\/ \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u0438 \u0445\u043e\u0442\u0435\u043b\u0438  \/\/ \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e first \u0438 last \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \/\/ \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f? \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0445 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \/\/ \u0438 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f 0 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 const&amp; \u0445\u0443\u0436\u0435. <\/code><\/pre>\n<p>  \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 &amp;&amp; \u0442\u0430\u043a\u0436\u0435 \u0445\u0443\u0436\u0435, \u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443:<\/p>\n<pre><code class=\"cpp\">\/\/ \u0421\u0442\u0440\u0430\u043d\u043d\u043e\u0432\u0430\u0442\u043e. struct person {   person(std::string&amp;&amp; first_name, std::string&amp;&amp; last_name)     : first_name{std::move(first_name)}     , last_name{std::move(last_name)}   {} private:   std::string first_name;   std::string last_name; };  std::string first{\"abc\"}, last{\"def\"}; person p1{std::move(first), std::move(last)}; \/\/ \u043d\u043e\u0440\u043c \/\/ \u043d\u043e \u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u043c\u044b \u041d\u0415 \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 &amp;&amp; \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0445\u0438\u0442\u0440\u0438\u0442\u044c: person p2{std::string{first}, std::string{last}}; \/\/ FOOOO <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435 \u0431\u043e\u0438\u0442\u0435\u0441\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0437\u0440\u044b\u0432\u0430, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0442\u044c \u0448\u0430\u043d\u0441 &amp;&amp; (\u043d\u043e \u0437\u0430\u0447\u0435\u043c? \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0430 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u0434\u0440\u0435\u043c\u043b\u0435\u0442):<\/p>\n<pre><code class=\"cpp\">\/\/ \u041f\u043e\u0436\u0430\u043b\u0435\u0439\u0442\u0435 \u0441\u0432\u043e\u044e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443. struct person {   person(std::string&amp;&amp; first_name, std::string&amp;&amp; last_name)     : first_name{std::move(first_name)}     , last_name{std::move(last_name)} {}   person(const std::string&amp; first_name, std::string&amp;&amp; last_name)     : first_name{first_name}     , last_name{std::move(last_name)} {}   person(std::string&amp;&amp; first_name, const std::string&amp; last_name)     : first_name{std::move(first_name)}     , last_name{last_name} {}   person(const std::string&amp; first_name, const std::string&amp; last_name)     : first_name{first_name}     , last_name{last_name} {} private:   std::string first_name;   std::string last_name; }; <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0432\u043e\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 (\u043d\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0437\u0430\u0447\u0435\u043c?):<\/p>\n<pre><code class=\"cpp\">\/\/ \u0417\u0430\u0443\u043c\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 (\u0438\u0437 \u043f\u0443\u0448\u043a\u0438 \u043f\u043e \u0432\u043e\u0440\u043e\u0431\u044c\u044f\u043c), \u0445\u043e\u0442\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u043e\u0440\u043c. struct person {   template &lt;typename T1, typename T2&gt;   person(T1&amp;&amp; first_name, T2&amp;&amp; last_name)     : first_name{std::forward&lt;T1&gt;(first_name)}     , last_name{std::forward&lt;T2&gt;(last_name)} {} private:   std::string first_name;   std::string last_name; };<\/code><\/pre>\n<p>  \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435 std::string, \u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u044e\u0434\u0435\u0439 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u0435\u0433\u043e (\u0430 \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c), \u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0435\u0436\u0435\u043b\u0438 \u0432\u0435\u0437\u0434\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e &amp;&amp;. \u0422\u0430\u043a \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435, \u0434\u0430 \u0438 \u043a\u043e\u0434 \u043a\u043e\u0440\u043e\u0447\u0435.<\/p>\n<p>  \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043f\u0430\u0440\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u041d\u0415 \u0421\u0422\u041e\u0418\u0422:<\/p>\n<pre><code class=\"cpp\">\/\/ \u041a\u043e\u0448\u043c\u0430\u0440\u043d\u043e. struct person {   person(const std::string&amp; first_name, const std::string&amp; last_name)     : first_name{first_name}     , last_name{last_name}   {} private:   \/\/ \u041d\u0415\u0422 \u0438 \u041d\u0415\u0422: \u044d\u0442\u043e \u043c\u0435\u0433\u0430\u043e\u043f\u0430\u0441\u043d\u043e, \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0439\u0442\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435   \/\/ \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430   const std::string&amp; first_name;   const std::string&amp; last_name; };  person p{\"x\", \"y\"}; \/\/ \u0445\u0430-\u0445\u0430-\u0445\u0430, \u043f\u0440\u0438\u0435\u0445\u0430\u043b\u0438 <\/code><\/pre>\n<p>  \u0418 \u0442\u0430\u043a \u0442\u043e\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e:<\/p>\n<pre><code class=\"cpp\">\/\/ \u041f\u043b\u043e\u0445\u043e\u0432\u0430\u0442\u043e. struct person {   person(std::string&amp; first_name, std::string&amp; last_name)     : first_name{first_name}     , last_name{last_name}   {} private:   \/\/ \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435 \u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f shared_ptr:   \/\/ \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043d\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e   std::string&amp; first_name;   std::string&amp; last_name; }; <\/code><\/pre>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u0430\u043a\u043e\u0432 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f? \u041e\u043d \u043f\u0440\u043e\u0441\u0442: \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u0412\u041b\u0410\u0414\u0415\u0422\u042c \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0447\u0435\u043c-\u0442\u043e \u0432\u043b\u0430\u0434\u0435\u0442\u044c, \u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u043b\u0430\u0434\u0435\u0442\u044c shared_ptr&#8217;\u043e\u043c \u043d\u0430 \u044d\u0442\u043e \u00ab\u0447\u0442\u043e-\u0442\u043e\u00bb. \u041a\u0441\u0442\u0430\u0442\u0438, shared_ptr&#8217;\u044b \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u0436\u0435 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u043d\u0435 \u043f\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 \u0442\u0443\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441 \u0441\u0430\u043c\u044b\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cpp\">\/\/ \u041b\u0443\u0447\u0448\u0435 (\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u0430). struct person {   person(std::shared_ptr&lt;portfolio&gt; pf)      : pf{std::move(pf)} \/\/ std::move \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438   {} private:   std::shared_ptr&lt;portfolio&gt; pf; };  auto psh = std::make_shared&lt;portfolio&gt;(\"xxx\", \"yyy\", \"zzz\"); ... person p1{psh}; person p2{std::move(psh)}; \/\/ (X) \u0442\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 psh \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: std::move \u0434\u043b\u044f shared_ptr \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u0430\u043b\u0435\u043d, \u043e\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0441\u0441\u044b\u043b\u043e\u043a shared_ptr \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0441\u043e\u0442\u043d\u0438 \u0446\u0438\u043a\u043b\u043e\u0432 CPU) \u0438 \u043d\u0430 \u0435\u0433\u043e \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442. \u041e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0435\u0433\u043e. \u041d\u043e (X) \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0430 psh \u0432 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>  \u041c\u043e\u0440\u0430\u043b\u044c: \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 const&amp; \u043f\u043e\u0432\u0430\u043b\u044c\u043d\u043e. \u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043f\u043e \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u043c.<\/p>\n<p>  P.S.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 {} \u0432\u043c\u0435\u0441\u0442\u043e () \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u041c\u043e\u0434\u043d\u043e, \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043c\u043e\u043b\u043e\u0434\u0435\u0436\u043d\u043e.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/460955\/\"> https:\/\/habr.com\/ru\/post\/460955\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0421\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u043c <a href=\"https:\/\/habr.com\/ru\/post\/460831\/#comment_20416435\">habr.com\/ru\/post\/460831\/#comment_20416435<\/a> \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0435\u0439\u0441\u044f \u0442\u0430\u043c \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u0438, \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0441\u0435\u0442\u0442\u0435\u0440. \u041d\u0430 StackOverflow \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u043e, \u043d\u043e \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u044f \u043d\u0435 \u043f\u0440\u0438\u043f\u043e\u043c\u043d\u044e.<\/p>\n<p>  \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d, \u0438 \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043f\u0440\u0430\u0432. \u0412\u043e\u0442 \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">\/\/ \u0425\u043e\u0440\u043e\u0448\u043e. struct person {   person(std::string first_name, std::string last_name)     : first_name{std::move(first_name)} \/\/ \u0432\u0435\u0440\u043d\u043e     , last_name{std::move(last_name)} \/\/ std::move \u0437\u0434\u0435\u0441\u044c \u0421\u0423\u0429\u0415\u0421\u0422\u0412\u0415\u041d\u0415\u041d!   {} private:   std::string first_name;   std::string last_name; }; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 (\u043d\u0443 \u043b\u0430\u0434\u043d\u043e, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:  <\/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-292412","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292412","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=292412"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292412\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}