{"id":163907,"date":"2012-12-26T13:51:03","date_gmt":"2012-12-26T09:51:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=163907"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=163907","title":{"rendered":"<span class=\"post_title\">\u0427\u0438\u0441\u0442\u044b\u0439 \u0421++: \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u0442\u044c<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/dff\/823\/718\/dff823718d0816ff96eff0f48c819116.jpg\"\/><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, <a href=\"http:\/\/habrahabr.ru\/company\/intel\/blog\/156863\/\">\u0421\u0435\u0440\u0435\u0433\u0430<\/a> \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0434\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0435\u0442 \u043e C++. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0435\u0449\u0435 \u0432 C++ \u043d\u0443\u0436\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0435 \u0433\u0440\u0430\u0431\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u043c\u0435\u0448\u0430\u0442\u044c \u0434\u0432\u0430 \u044f\u0437\u044b\u043a\u0430. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0432\u044b\u0434\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442 C++ \u0435\u0449\u0435 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d \u0414\u041e\u0421\u0430. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u2014 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u0432\u044b, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c \u2014 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440! \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0412\u0421\u0415\u0413\u0414\u0410, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u0435\u0442\u0441\u044f. \u041d\u0435 \u0432\u0430\u0436\u043d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. (\u0414\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0438, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043b\u043e\u0432\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 main \u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c try&#8230;catch \u043d\u0430 \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.). \u041d\u0430 C \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0447\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439.  <\/p>\n<pre><code class=\"cpp\">if(!Create1(...))     return -1; if(!Create2(...)) {     Destroy1(...);     return -1; } \u2026 if(!CreateN(...)) {     Destroy1(...);     Destroy2(...);     ...     DestroyN-1(...);     return -1; } <\/code><\/pre>\n<p>  \u0410 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0446\u0438\u043a\u043b\u044b \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e\u0441\u0442\u0438 \u0432 \u043a\u043e\u0434\u0435.<br \/>  \u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u043a\u0446\u0438\u0435\u0439 finalize, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445! \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u043a\u043e\u0433\u043e \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0430 \u043a\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 finalize \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0438\u0437\u043b\u0438\u0448\u043d\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u043c. \u0412\u043e\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdexcept&gt;  class Foo { private:     static int sm_count;     int instance; public:     Foo()     {         instance = ++sm_count;         if(instance &gt; 5)             throw std::runtime_error(&quot;\u041d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 5\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.&quot;);         std::cout &lt;&lt; &quot;\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u2116 &quot; &lt;&lt; instance &lt;&lt; &quot; \u043a\u043b\u0430\u0441\u0441\u0430 Foo \u0441\u043e\u0437\u0434\u0430\u043d.\\n&quot;;      }     ~Foo()     {         std::cout &lt;&lt; &quot;\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u2116 &quot; &lt;&lt; instance &lt;&lt; &quot; \u043a\u043b\u0430\u0441\u0441\u0430 Foo \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d.\\n&quot;;     } };  int Foo::sm_count = 0;  int main() {     try     {         Foo* pFoo = new Foo[10];     }     catch(const std::exception& e)     {         std::cout &lt;&lt; e.what() &lt;&lt; &quot;\\n&quot;;     }     return 0; }  <\/code><\/pre>\n<p>  \u0413\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0435 \u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u0442 C++ \u043f\u043e \u0441\u0442\u0438\u043b\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u044f\u0437\u044b\u043a\u0430\u043c \u0441\u043e \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u043c \u043c\u0443\u0441\u043e\u0440\u0430. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0437\u0430\u043d\u044f\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u043d\u0435 \u0432\u044b\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043c\u0430\u043d\u0447\u0438\u0432\u043e \u0438 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441 \u043a\u0443\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0438 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u044b\u043c \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0449\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 \u044f\u0437\u044b\u043a\u0430 C (\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u00ab\u0426 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438\u00bb), \u0442\u043e \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0447\u0435\u0440\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0438\u043f. \u0412\u043e\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 (\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0445 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f):  <\/p>\n<pre><code class=\"cpp\">\/\/ HeaderFile1  class Interface1 { public:     virtual void SomeFunc(int a) = 0; };  class Interface2 { public:     virtual void AnotherFunc(double b) = 0; };  \/\/ HeaderFile2  class Implementation;  class Storage { private:     Implementation* m_pImpl; public:     Storage(Implementation* in_pImpl)         : m_pImpl(in_pImpl)     {}      Interface1* GetInterface1()     {         return (Interface1*)m_pImpl;     }     Interface2* GetInterface2()     {         return (Interface2*)m_pImpl;     } };  \/\/ HeaderFile3  #include &lt;iostream&gt;  class ImplementationBase { protected:     virtual void BaseFunc()     {         std::cout &lt;&lt; &quot;BaseFunc \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430.\\n&quot;;     } };  class Implementation     : private ImplementationBase     , public Interface1     , public Interface2 { public:     virtual void SomeFunc(int a)     {         std::cout &lt;&lt; &quot;SomeFunc \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c a = &quot; &lt;&lt; a &lt;&lt; &quot;.\\n&quot;;     }      virtual void AnotherFunc(double b)     {         std::cout &lt;&lt; &quot;AnotherFunc \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c b = &quot; &lt;&lt; b &lt;&lt; &quot;.\\n&quot;;     } };  \/\/ C++ source file \/\/ #include &lt;HeaderFile1&gt; \/\/ #include &lt;HeaderFile2&gt; \/\/ #include &lt;HeaderFile3&gt;  int main() {     Implementation impl;     Storage storage(&impl);     storage.GetInterface1()-&gt;SomeFunc(42);     storage.GetInterface2()-&gt;AnotherFunc(37.7);     return 0; }  <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c, \u043a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041a\u043e\u0433\u0434\u0430-\u0436\u0435 \u043a\u043e\u0434 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d \u043f\u043e \u043c\u043d\u043e\u0433\u0438\u043c \u0444\u0430\u0439\u043b\u0430\u043c, \u0441\u043a\u0440\u044b\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0443\u0440\u043e\u0432\u043d\u044f\u043c\u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0442\u043e \u043b\u0435\u0433\u0447\u0435 \u0441\u043e\u0439\u0442\u0438 \u0441 \u0443\u043c\u0430, \u0447\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e-\u0436\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 C++, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u043c. \u041f\u0440\u0438 \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u043c\u043e\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0440\u0430\u0437\u043c\u043e\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430 \u043d\u0438\u043c\u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u0435. \u041d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0432 \u043d\u0438\u0445 \u043f\u0430\u043c\u044f\u0442\u044c, \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0443\u0436 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u0431\u0440\u043e\u0441\u0430\u0439\u0442\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u044f\u0432\u043d\u043e. \u042d\u0442\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u043a\u0442\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u043e \u0432\u0441\u044f\u043a\u0438\u043c \u00ab\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a\u043e\u0439 \u043d\u0438\u0431\u0443\u0434\u044c <code>Socket::Close()<\/code> \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>throw std::runtime_error(&quot;Close socket error: socket was not opened&quot;)<\/code>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u00ab\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u2014 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435. \u0410 \u0432\u043e\u0442 \u043e\u0431\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u2014 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0430\u0436\u0435 \u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e. \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u0435, \u0442\u043e \u043a\u0442\u043e-\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0435. \u0422\u0430\u043a-\u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0441\u0435\u0431\u0435 \u043a\u0443\u0434\u0430 \u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u0432 \u043b\u044e\u0431\u043e\u0439 \u00ab\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0442\u0438\u0445\u043e \u0438 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u0442 \u043d\u0435\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u00ab\u0437\u0430\u043a\u0440\u044b\u0442\u044c\u00bb \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u044f\u0442, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<br \/>  \u0415\u0449\u0435 \u0440\u0430\u0437 \u043e\u0431\u0440\u0430\u0449\u0430\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u043d\u0438\u0447\u0435\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c. \u041e\u0447\u0435\u043d\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430:  <\/p>\n<pre><code class=\"cpp\">~object::object() {     g_logger.put_message(std::string(&quot;Object &quot;) + m_name + std::string(&quot; was deleted.&quot;)); } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0430 \u00ab\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u043f\u0430\u043c\u044f\u0442\u044c\u00bb, \u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432\u044b\u043b\u0435\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0442\u0443\u0442 \u043b\u043e\u0433\u0433\u0435\u0440 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u0442.\u043a. \u043d\u0435 \u0441\u0443\u043c\u0435\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u0430\u043a \u043d\u0443\u0436\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u041a\u0430\u043a-\u0436\u0435 \u0431\u044b\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438? \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043d\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439\u00bb \u2014 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0440\u0430\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043e \u043f\u043e\u0440\u044b \u0434\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0411\u043e\u043b\u0435\u0435 \u00ab\u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439\u00bb \u0432\u0430\u0440\u0438\u0430\u043d\u0442:  <\/p>\n<pre><code class=\"cpp\">~object::object() {     g_logger &lt;&lt; &quot;Object &quot; &lt;&lt; m_name &lt;&lt; &quot; was deleted.&quot;; } <\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e g_logger \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u043e\u0431\u044f\u0437\u0430\u043d \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u0433\u043e\u0442\u043e\u0432\u0435 \u0431\u0443\u0444\u0444\u0435\u0440 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u0441\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e?<\/p>\n<p>  \u041f\u043b\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0412\u043e\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"cpp\"> std::vector&lt;int&gt; items; ... items.push_back(item1); items.push_back(item2); \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a: std::vector&lt;int&gt; items; ... items.reserve(items.size() + 2); items.push_back(item1); items.push_back(item2);  <\/code><\/pre>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0432 \u0441\u0430\u043c\u044b\u0439 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0431\u044f\u0437\u0430\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u043e\u0431\u044f\u0437\u0430\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u043b\u0438\u0431\u043e \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445, \u043b\u0438\u0431\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u00ab\u043d\u0435\u0434\u043e\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445\u00bb \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e, \u0442.\u043a. \u044d\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0443\u0442\u044c \u043a \u0441\u0431\u043e\u044e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0442\u0438\u0445\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442. \u041d\u0443, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u0438\u0445\u043e, \u0430 \u0432\u0435\u0436\u043b\u0438\u0432\u043e \u043f\u043e\u043f\u0440\u043e\u0449\u0430\u0432\u0448\u0438\u0441\u044c. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>std::list<\/code> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 reserve. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u0432\u043e\u0434\u0438\u0442\u044c \u00ab\u043f\u0443\u0441\u0442\u043e\u0435\u00bb \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0440\u043e\u0434\u0435 null_ptr \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u043b\u0438 -1 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0438 \u043a\u043b\u0430\u0441\u0442\u044c \u0435\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410 \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0417\u0434\u0435\u0441\u044c \u0443\u043c\u0435\u0441\u0442\u043d\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e \u0443\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u044f\u043a\u0438\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u042d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f, \u0430 \u0431\u0440\u043e\u0441\u0430\u044e\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u044f\u043c\u043e \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0447\u0430\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u0443\u0432\u044b\u0447\u0435\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c ++ \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 catch.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0430\u0441\u044c \u0441\u0430\u043c\u0430 \u0441\u043e\u0431\u043e\u0439, \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u044f\u043a\u0438\u0435 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437 \u0441\u0435\u0431\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u043b\u0438\u0441\u044c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u043c\u0438, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0435\u0431\u044f \u0438\u0437 \u043e\u0431\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\"> typedef std::pair&lt;int, int&gt; DataItem; std::vector&lt;DataItem&gt; items; ... items.push_back(DataItem(item1, item2));  <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0435\u043c\u0430 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.    \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\/company\/intel\/blog\/163907\/\"> http:\/\/habrahabr.ru\/company\/intel\/blog\/163907\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/dff\/823\/718\/dff823718d0816ff96eff0f48c819116.jpg\"\/><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, <a href=\"http:\/\/habrahabr.ru\/company\/intel\/blog\/156863\/\">\u0421\u0435\u0440\u0435\u0433\u0430<\/a> \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0434\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0435\u0442 \u043e C++. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0435\u0449\u0435 \u0432 C++ \u043d\u0443\u0436\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0435 \u0433\u0440\u0430\u0431\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u043c\u0435\u0448\u0430\u0442\u044c \u0434\u0432\u0430 \u044f\u0437\u044b\u043a\u0430. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0432\u044b\u0434\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442 C++ \u0435\u0449\u0435 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d \u0414\u041e\u0421\u0430. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u2014 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.  <\/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-163907","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163907","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=163907"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163907\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}