{"id":334714,"date":"2022-06-19T21:00:11","date_gmt":"2022-06-19T21:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334714"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334714","title":{"rendered":"<span>Holy C++<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0437\u0430\u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u0438\u0437 \u0421++ \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u043d\u0438\u0447\u0435\u0433\u043e(\u043a\u0440\u043e\u043c\u0435 \u0431\u043e\u043b\u0438), \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432, \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u044f\u0437\u044b\u043a \u0438 \u043c\u0435\u043c\u043e\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u043e\u0441\u0442\u0438 \u0421++<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u044f\u0437\u044b\u043a\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0447\u0430\u0441\u0442\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0438 \u043c\u0435\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e \u044f\u0437\u044b\u043a\u0430, \u0442\u0443\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c<\/p>\n<p><strong>1 &#8212; union <\/strong>&#8212; \u0441\u0443\u043c\u043c \u0442\u0438\u043f \u0438\u0437 70\u0445, \u0432 \u0421 \u0438\u0434\u0435\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0438 \u0441\u0435\u0439\u0447\u0430\u0441, \u0432\u0435\u0434\u044c \u0442\u0430\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c.<\/p>\n<p>\u0412 \u0421++ \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 union \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 undefined behavior, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#include &lt;string> union A { int x; float y;}; union B {   B() {} \/\/ \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   \/\/ \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e   \/\/ (\u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u0435\u0440\u0438\u0442\u0435)   ~B() {}   std::string s;   int x; }; int main() {   A value;   value.x = 5;   value.y; \/\/ undefined behavior, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0447\u043b\u0435\u043d\u0443 union   B value2;   value2.s = \"hello world\";   \/\/ undefined behavior, \u043f\u043e\u043b\u0435 s \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f    \/\/ (\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435= \u0434\u043b\u044f std::string) }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c union \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0430\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u043b\u0430\u0442\u044c placement new \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u043e\u043b\u0435. \u0422\u0430\u043a \u0437\u0430\u0447\u0435\u043c \u0436\u0435 \u0442\u0430\u043a \u043c\u0443\u0447\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0411\u0415\u0417 \u043a\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044e\u043d\u0438\u043e\u043d\u0430?<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u044e\u043d\u0438\u043e\u043d, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0433\u043e \u0438 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (emplace \/ destroy)<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435 \u0421++<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename ... Ts> struct union_t {   alignas(std::ranges::max({alignof(Ts)...})   std::byte data[std::ranges::max({sizeof(Ts)...});      template&lt;one_of&lt;Ts...> U>   constexpr U&amp; emplace(auto&amp;&amp;... args) {     return std::launder(new(data) U{std::forward&lt;decltype(args)>(args)....});   }   template&lt;one_of&lt;Ts...> U>   constexpr void destroy_as() const {     reintepret_cast&lt;const U*>(reinterpret_cast&lt;void*>(data))->~U();   } };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u043e\u0441\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f union, \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e\u0442 \u043e\u0442\u0433\u043e\u043b\u043e\u0441\u043e\u043a \u0421, \u0432 2022-\u0442\u043e \u0433\u043e\u0434\u0443&#8230;<\/p>\n<p><strong>2 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0432\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e \u043c\u044b \u043f\u0440\u0430\u0432\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0421++ \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u043d\u0438\u0447\u0435\u0433\u043e (\u0443\u0431\u0440\u0430\u0432 \u044d\u0442\u043e\u0442 \u0447\u0443\u0434\u043e\u0432\u0438\u0449\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <strong>char(&amp;&amp;&#8230;arr)[N]<\/strong> (\u0443\u0433\u0430\u0434\u0430\u0439\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442) )<\/p>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b \u0438 \u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u0432 \u043c\u0443\u0432 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u0441\u0430\u043c\u044b\u043c\u0438 \u043d\u0435\u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0432\u043e \u0432\u0441\u0451\u043c \u044f\u0437\u044b\u043a\u0435<\/p>\n<p>\u041a\u0430\u043a \u0436\u0435 \u0438\u0445 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c? \u0420\u0435\u043a\u0443\u0441\u0438\u0432\u043d\u044b\u043c(\u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435) \u0442\u0443\u043f\u043b\u043e\u043c \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430(\u0434\u0430, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e)))<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0430\u043a\u0442:<\/summary>\n<div class=\"spoiler__content\">\n<p> \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0421++ \u0435\u0441\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0430\u0436 \u0432 \u0446\u0438\u043a\u043b\u0435 for \u0434\u043b\u044f \u0441\u0438\u0448\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432&#8230; \u0427\u0442\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0431\u0435\u0437\u0443\u043c\u043d\u043e \u043f\u043b\u043e\u0445\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0435\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename T, size_t I> struct array_value { T value; }; template&lt;typename, typename> struct array_impl; template&lt;typename T, size_t... Is> struct array_impl&lt;T, std::index_sequence&lt;Is...>> : array_value&lt;T, Is>...{};  template&lt;typename T, size_t N> struct array_ : array_impl&lt;T, std::make_index_sequence&lt;N>> {   \/\/ \u0442\u0443\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u0436\u0435\u043b\u0430\u043d\u0438\u044e     T&amp; operator[](size_t n) {         \/\/ \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438         return *(reinterpret_cast&lt;T*>(reinterpret_cast&lt;void*>(this)) + n);     } };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p><strong>3 &#8212; \u0442\u0438\u043f void<\/strong><\/p>\n<p><strong>void<\/strong> \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u0431\u044b\u043b\u043e \u0431\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0438\u043c\u0435\u0442\u044c \u0442\u0438\u043f \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0430\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c&#8230; \u041a\u0430\u043a \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f&#8230;.<\/p>\n<pre><code class=\"cpp\">struct [[maybe_unused]] nulltype {};  \/\/ \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451... \u0414\u0430 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442 [[maybe_unused]] \u0442\u0443\u0442 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b<\/code><\/pre>\n<p><strong>4 &#8212; \u0432\u0441\u0435 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b&#8230;<br \/><\/strong>\u041a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u044b \u0438\u0434\u0451\u043c \u043f\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439, \u043d\u0430 \u0447\u0442\u043e \u0436\u0435 \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0443\u0442 \u0437\u0430\u043c\u0430\u0445\u043d\u0443\u043b\u0441\u044f? \u041d\u0430 int?!<\/p>\n<p>\u0414\u0430, \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0441\u044c \u0432 \u0421 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u0421++ \u0438\u0445 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b. \u041a\u0442\u043e \u0432 \u0437\u0434\u0440\u0430\u0432\u043e\u043c \u0443\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>int<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 8 \u0431\u0430\u0439\u0442, \u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e 2 ^ 16??? \u042d\u0442\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u043e\u043a(\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432)<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c <strong>byte \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, <\/strong>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e: \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>byte<\/strong> \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0421++ \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0442\u0438\u043f\u044b, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 <strong>int, double, float, bool<\/strong> \u0438 \u0442.\u0434. \u0438\u0437 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430<br \/>\u0422\u0443\u0442 \u043c\u044b \u0443\u0431\u0438\u0432\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0439\u0446\u0435\u0432 &#8212; \u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f( \u043e\u0442 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f) \u043d\u0443 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0435<\/p>\n<p><strong>4.5 &#8212; \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438\u0437 \u0421 &#8212; <\/strong>\u044d\u0442\u043e.\u043f\u0440\u043e\u0441\u0442\u043e.\u043d\u0435.\u0434\u043e\u043b\u0436\u043d\u043e.\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. (\u043d\u043e \u043e\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f) <a href=\"https:\/\/godbolt.org\/z\/fz6eMEeqG\" rel=\"noopener noreferrer nofollow\">https:\/\/godbolt.org\/z\/fz6eMEeqG<\/a><\/p>\n<pre><code class=\"cpp\">int main() {     (void)(5), (void)5, void(5); } <\/code><\/pre>\n<p><strong>5 &#8212; runtime variadic arguments<\/strong> &#8212; \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u044d\u0442\u0443 \u0432\u0435\u0449\u044c \u0432 \u0421 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u043a\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u044d\u0442\u043e\u0442 \u0433\u0440\u0435\u0445, \u043d\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0433\u043e \u0442\u044f\u043d\u0443\u0442\u044c.<\/p>\n<p>\u0418 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u044b\u0439 printf(const char* pattern, &#8230; ) &lt;- \u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u043c\u043d\u043e\u0433\u043e\u0442\u043e\u0447\u0438\u0435 \u044d\u0442\u043e \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b! \u041b\u044e\u0431\u044b\u0435! \u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f&#8230; \u0423\u0445&#8230; \u043c\u0430\u043a\u0440\u043e\u0441\u044b __VA_START__ __VA_COPY__ \u0438 \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u0430\u044f \u043a\u0443\u0447\u0430 \u0435\u0449\u0451 \u0432\u0441\u0435\u0433\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u044d\u0442\u0438\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0448\u043c\u0430\u0440\u0430\u0445 \u0441\u0438\u0448\u043d\u0438\u043a\u0430\u043c \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438, \u0430 \u0421++ \u043f\u043e\u0436\u0430\u043b\u0443\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0430 \u0438\u0437 \u044f\u0437\u044b\u043a\u0430 \u0438 \u0437\u0430\u0431\u044b\u0442\u044c(\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u043a\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432)<\/p>\n<p><strong>6 &#8212; typedef<\/strong> &#8212; \u043d\u0443 \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0432 \u0421++ \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">typedef void(*foo)(int); \/\/ foo \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u043b\u0438\u0430\u0441 \u043d\u0430 void(*)(int) (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e) \/\/ \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u043d\u0430 \u0421++ using foo = void(*)(int);<\/code><\/pre>\n<p>\u0421\u043c\u044b\u0441\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c typedef \u0432 \u044f\u0437\u044b\u043a\u0435 \u043d\u0435\u0442&#8230;))<\/p>\n<p><strong>7 &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b<\/strong> &#8212; \u044d\u0442\u043e \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0438\u0437 \u0421, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u0438\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430(\u043f\u043b\u043e\u0445\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432\u0435\u0434\u044c \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u043b\u044e\u0441\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e)<\/p>\n<p>\u0412\u043e\u0442, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u0442\u0438\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0441\u044c \u0421 \u0438\u0437 \u0421++ \u0438 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0447\u0438\u0441\u0442\u044b\u0435 ++(\u043f\u043b\u044e\u0441\u044b). \u041f\u043e\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0443\u0442!<\/p>\n<p><strong>8 &#8212; \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b new \u0438 delete<\/strong><\/p>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u0432 \u044f\u0437\u044b\u043a\u0435 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 malloc?! \u041a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443(\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u043f\u0430\u043c\u044f\u0442\u0438) \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u044f\u0437\u044b\u043a\u0430?<\/p>\n<p>\u0412\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e new<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0422\u0420\u0410\u0428\u041d\u041e<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/48e\/666\/fb2\/48e666fb266693aa7ca53598c0458b63.png\" width=\"744\" height=\"919\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48e\/666\/fb2\/48e666fb266693aa7ca53598c0458b63.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 new \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 new \/ delete \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++ \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0441 \u0437\u0430\u0441\u043c\u0435\u044f\u043b\u0438<\/p>\n<p><strong>9 &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e class<\/strong> &#8212; \u043d\u0443 \u0442\u0443\u0442 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u044e \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/662351\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/662351\/<\/a><\/p>\n<p><strong>10 &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e final<\/strong> (\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0438\u043f\u0430) &#8212; \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043c\u043d\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043b\u043e\u043c\u0430\u0435\u0442 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432\u0435\u0440\u0434\u0438\u043a\u0442 &#8212; \u0443\u0434\u0430\u043b\u0438\u0442\u044c<\/p>\n<p><strong>11 &#8212; \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b :<\/strong><\/p>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u0443\u044e \u043a\u0443\u0447\u0443 \u043e\u0448\u0438\u0431\u043e\u043a<\/p>\n<p>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b, \u0441\u0442\u0438\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0437\u044b\u043a, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e virtual, \u0438 \u0421\u0410\u041c\u041e\u0415 \u0413\u041b\u0410\u0412\u041d\u041e\u0415 &#8212; \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430(\u0438 \u0441 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0442.\u0434&#8230;.)<br \/>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0431\u0435\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c: <a href=\"https:\/\/github.com\/kelbon\/AnyAny\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/kelbon\/AnyAny<\/a><\/p>\n<p><strong>12 &#8212; \u043c\u0435\u0442\u043e\u0434\u044b<\/strong> ( \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 )<\/p>\n<p>\u0412 \u0421++23 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f(\u043d\u0430\u043a\u043e\u043d\u0435\u0446) deducing this, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043d\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 this \u0432 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0438\u043f\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u043e\u0439 &#171;\u043c\u0435\u0442\u043e\u0434&#187; \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439(\u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430), \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c(\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432) \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u041c\u0415\u0422\u041e\u0414 \u0432 \u044f\u0437\u044b\u043a\u0435 \u0421++(\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u044d\u0442\u0443 \u0432\u0435\u0449\u044c)  (\u043d\u0435 \u0434\u0430\u0439 \u0431\u043e\u0436\u0435 \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0434 \u0441\u043d\u043e\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043c\u0435\u0442\u043e\u0434)<\/p>\n<pre><code class=\"cpp\">struct A { void foo(this A&amp; self); };<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e this \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0435\u0436\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u043e\u0435 &#8212; \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u044f\u0432\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u0441\u044b\u043b\u043a\u0438\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451, \u043f\u043e\u043c\u0435\u0447\u0442\u0430\u043b\u0438 \u043e \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u043e\u043c hole C++, \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u0442\u0438 \u0438 \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0440\u0435\u043d\u044c \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0437\u0430\u0431\u044b\u0442\u044b\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u043d\u0430 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u043e\u043c \u0442\u0438\u043f\u0435 \u0438 \u0441\u0438\u0448\u043d\u044b\u043c\u0438 \u043a\u0430\u0441\u0442\u0430\u043c\u0438, \u0443\u0434\u0430\u0447\u0438&#8230; <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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\/672282\/\"> https:\/\/habr.com\/ru\/post\/672282\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0437\u0430\u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u0438\u0437 \u0421++ \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u043d\u0438\u0447\u0435\u0433\u043e(\u043a\u0440\u043e\u043c\u0435 \u0431\u043e\u043b\u0438), \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432, \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u044f\u0437\u044b\u043a \u0438 \u043c\u0435\u043c\u043e\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u043e\u0441\u0442\u0438 \u0421++<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u044f\u0437\u044b\u043a\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0447\u0430\u0441\u0442\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0438 \u043c\u0435\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e \u044f\u0437\u044b\u043a\u0430, \u0442\u0443\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c<\/p>\n<p><strong>1 &#8212; union <\/strong>&#8212; \u0441\u0443\u043c\u043c \u0442\u0438\u043f \u0438\u0437 70\u0445, \u0432 \u0421 \u0438\u0434\u0435\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0438 \u0441\u0435\u0439\u0447\u0430\u0441, \u0432\u0435\u0434\u044c \u0442\u0430\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c.<\/p>\n<p>\u0412 \u0421++ \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 union \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 undefined behavior, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#include &lt;string> union A { int x; float y;}; union B {   B() {} \/\/ \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   \/\/ \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e   \/\/ (\u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u0435\u0440\u0438\u0442\u0435)   ~B() {}   std::string s;   int x; }; int main() {   A value;   value.x = 5;   value.y; \/\/ undefined behavior, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0447\u043b\u0435\u043d\u0443 union   B value2;   value2.s = \"hello world\";   \/\/ undefined behavior, \u043f\u043e\u043b\u0435 s \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f    \/\/ (\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435= \u0434\u043b\u044f std::string) }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c union \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0430\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u043b\u0430\u0442\u044c placement new \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u043e\u043b\u0435. \u0422\u0430\u043a \u0437\u0430\u0447\u0435\u043c \u0436\u0435 \u0442\u0430\u043a \u043c\u0443\u0447\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0411\u0415\u0417 \u043a\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044e\u043d\u0438\u043e\u043d\u0430?<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u044e\u043d\u0438\u043e\u043d, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0433\u043e \u0438 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (emplace \/ destroy)<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435 \u0421++<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename ... Ts> struct union_t {   alignas(std::ranges::max({alignof(Ts)...})   std::byte data[std::ranges::max({sizeof(Ts)...});      template&lt;one_of&lt;Ts...> U>   constexpr U&amp; emplace(auto&amp;&amp;... args) {     return std::launder(new(data) U{std::forward&lt;decltype(args)>(args)....});   }   template&lt;one_of&lt;Ts...> U>   constexpr void destroy_as() const {     reintepret_cast&lt;const U*>(reinterpret_cast&lt;void*>(data))->~U();   } };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u043e\u0441\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f union, \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e\u0442 \u043e\u0442\u0433\u043e\u043b\u043e\u0441\u043e\u043a \u0421, \u0432 2022-\u0442\u043e \u0433\u043e\u0434\u0443&#8230;<\/p>\n<p><strong>2 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0432\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e \u043c\u044b \u043f\u0440\u0430\u0432\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0421++ \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u043d\u0438\u0447\u0435\u0433\u043e (\u0443\u0431\u0440\u0430\u0432 \u044d\u0442\u043e\u0442 \u0447\u0443\u0434\u043e\u0432\u0438\u0449\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <strong>char(&amp;&amp;&#8230;arr)[N]<\/strong> (\u0443\u0433\u0430\u0434\u0430\u0439\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442) )<\/p>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b \u0438 \u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u0432 \u043c\u0443\u0432 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u0441\u0430\u043c\u044b\u043c\u0438 \u043d\u0435\u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0432\u043e \u0432\u0441\u0451\u043c \u044f\u0437\u044b\u043a\u0435<\/p>\n<p>\u041a\u0430\u043a \u0436\u0435 \u0438\u0445 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c? \u0420\u0435\u043a\u0443\u0441\u0438\u0432\u043d\u044b\u043c(\u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435) \u0442\u0443\u043f\u043b\u043e\u043c \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430(\u0434\u0430, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e)))<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0430\u043a\u0442:<\/summary>\n<div class=\"spoiler__content\">\n<p> \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0421++ \u0435\u0441\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0430\u0436 \u0432 \u0446\u0438\u043a\u043b\u0435 for \u0434\u043b\u044f \u0441\u0438\u0448\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432&#8230; \u0427\u0442\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0431\u0435\u0437\u0443\u043c\u043d\u043e \u043f\u043b\u043e\u0445\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0435\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename T, size_t I> struct array_value { T value; }; template&lt;typename, typename> struct array_impl; template&lt;typename T, size_t... Is> struct array_impl&lt;T, std::index_sequence&lt;Is...>> : array_value&lt;T, Is>...{};  template&lt;typename T, size_t N> struct array_ : array_impl&lt;T, std::make_index_sequence&lt;N>> {   \/\/ \u0442\u0443\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u0436\u0435\u043b\u0430\u043d\u0438\u044e     T&amp; operator[](size_t n) {         \/\/ \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438         return *(reinterpret_cast&lt;T*>(reinterpret_cast&lt;void*>(this)) + n);     } };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p><strong>3 &#8212; \u0442\u0438\u043f void<\/strong><\/p>\n<p><strong>void<\/strong> \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u0431\u044b\u043b\u043e \u0431\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0438\u043c\u0435\u0442\u044c \u0442\u0438\u043f \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0430\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c&#8230; \u041a\u0430\u043a \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f&#8230;.<\/p>\n<pre><code class=\"cpp\">struct [[maybe_unused]] nulltype {};  \/\/ \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451... \u0414\u0430 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442 [[maybe_unused]] \u0442\u0443\u0442 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b<\/code><\/pre>\n<p><strong>4 &#8212; \u0432\u0441\u0435 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b&#8230;<br \/><\/strong>\u041a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u044b \u0438\u0434\u0451\u043c \u043f\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439, \u043d\u0430 \u0447\u0442\u043e \u0436\u0435 \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0443\u0442 \u0437\u0430\u043c\u0430\u0445\u043d\u0443\u043b\u0441\u044f? \u041d\u0430 int?!<\/p>\n<p>\u0414\u0430, \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0441\u044c \u0432 \u0421 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u0421++ \u0438\u0445 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b. \u041a\u0442\u043e \u0432 \u0437\u0434\u0440\u0430\u0432\u043e\u043c \u0443\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>int<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 8 \u0431\u0430\u0439\u0442, \u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e 2 ^ 16??? \u042d\u0442\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u043e\u043a(\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432)<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c <strong>byte \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, <\/strong>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e: \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>byte<\/strong> \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0421++ \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0442\u0438\u043f\u044b, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 <strong>int, double, float, bool<\/strong> \u0438 \u0442.\u0434. \u0438\u0437 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430<br \/>\u0422\u0443\u0442 \u043c\u044b \u0443\u0431\u0438\u0432\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0439\u0446\u0435\u0432 &#8212; \u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f( \u043e\u0442 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f) \u043d\u0443 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0435<\/p>\n<p><strong>4.5 &#8212; \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438\u0437 \u0421 &#8212; <\/strong>\u044d\u0442\u043e.\u043f\u0440\u043e\u0441\u0442\u043e.\u043d\u0435.\u0434\u043e\u043b\u0436\u043d\u043e.\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. (\u043d\u043e \u043e\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f) <a href=\"https:\/\/godbolt.org\/z\/fz6eMEeqG\" rel=\"noopener noreferrer nofollow\">https:\/\/godbolt.org\/z\/fz6eMEeqG<\/a><\/p>\n<pre><code class=\"cpp\">int main() {     (void)(5), (void)5, void(5); } <\/code><\/pre>\n<p><strong>5 &#8212; runtime variadic arguments<\/strong> &#8212; \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u044d\u0442\u0443 \u0432\u0435\u0449\u044c \u0432 \u0421 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u043a\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u044d\u0442\u043e\u0442 \u0433\u0440\u0435\u0445, \u043d\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0433\u043e \u0442\u044f\u043d\u0443\u0442\u044c.<\/p>\n<p>\u0418 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u044b\u0439 printf(const char* pattern, &#8230; ) &lt;- \u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u043c\u043d\u043e\u0433\u043e\u0442\u043e\u0447\u0438\u0435 \u044d\u0442\u043e \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b! \u041b\u044e\u0431\u044b\u0435! \u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f&#8230; \u0423\u0445&#8230; \u043c\u0430\u043a\u0440\u043e\u0441\u044b __VA_START__ __VA_COPY__ \u0438 \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u0430\u044f \u043a\u0443\u0447\u0430 \u0435\u0449\u0451 \u0432\u0441\u0435\u0433\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u044d\u0442\u0438\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0448\u043c\u0430\u0440\u0430\u0445 \u0441\u0438\u0448\u043d\u0438\u043a\u0430\u043c \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438, \u0430 \u0421++ \u043f\u043e\u0436\u0430\u043b\u0443\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0430 \u0438\u0437 \u044f\u0437\u044b\u043a\u0430 \u0438 \u0437\u0430\u0431\u044b\u0442\u044c(\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u043a\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432)<\/p>\n<p><strong>6 &#8212; typedef<\/strong> &#8212; \u043d\u0443 \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0432 \u0421++ \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">typedef void(*foo)(int); \/\/ foo \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u043b\u0438\u0430\u0441 \u043d\u0430 void(*)(int) (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e) \/\/ \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u043d\u0430 \u0421++ using foo = void(*)(int);<\/code><\/pre>\n<p>\u0421\u043c\u044b\u0441\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c typedef \u0432 \u044f\u0437\u044b\u043a\u0435 \u043d\u0435\u0442&#8230;))<\/p>\n<p><strong>7 &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b<\/strong> &#8212; \u044d\u0442\u043e \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0438\u0437 \u0421, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u0438\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430(\u043f\u043b\u043e\u0445\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432\u0435\u0434\u044c \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u043b\u044e\u0441\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e)<\/p>\n<p>\u0412\u043e\u0442, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u0442\u0438\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0441\u044c \u0421 \u0438\u0437 \u0421++ \u0438 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0447\u0438\u0441\u0442\u044b\u0435 ++(\u043f\u043b\u044e\u0441\u044b). \u041f\u043e\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0443\u0442!<\/p>\n<p><strong>8 &#8212; \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b new \u0438 delete<\/strong><\/p>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u0432 \u044f\u0437\u044b\u043a\u0435 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 malloc?! \u041a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443(\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u043f\u0430\u043c\u044f\u0442\u0438) \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u044f\u0437\u044b\u043a\u0430?<\/p>\n<p>\u0412\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e new<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0422\u0420\u0410\u0428\u041d\u041e<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 new \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 new \/ delete \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++ \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0441 \u0437\u0430\u0441\u043c\u0435\u044f\u043b\u0438<\/p>\n<p><strong>9 &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e class<\/strong> &#8212; \u043d\u0443 \u0442\u0443\u0442 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u044e \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/662351\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/662351\/<\/a><\/p>\n<p><strong>10 &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e final<\/strong> (\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0438\u043f\u0430) &#8212; \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043c\u043d\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043b\u043e\u043c\u0430\u0435\u0442 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432\u0435\u0440\u0434\u0438\u043a\u0442 &#8212; \u0443\u0434\u0430\u043b\u0438\u0442\u044c<\/p>\n<p><strong>11 &#8212; \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b :<\/strong><\/p>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u0443\u044e \u043a\u0443\u0447\u0443 \u043e\u0448\u0438\u0431\u043e\u043a<\/p>\n<p>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b, \u0441\u0442\u0438\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0437\u044b\u043a, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e virtual, \u0438 \u0421\u0410\u041c\u041e\u0415 \u0413\u041b\u0410\u0412\u041d\u041e\u0415 &#8212; \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430(\u0438 \u0441 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0442.\u0434&#8230;.)<br \/>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0431\u0435\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c: <a href=\"https:\/\/github.com\/kelbon\/AnyAny\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/kelbon\/AnyAny<\/a><\/p>\n<p><strong>12 &#8212; \u043c\u0435\u0442\u043e\u0434\u044b<\/strong> ( \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 )<\/p>\n<p>\u0412 \u0421++23 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f(\u043d\u0430\u043a\u043e\u043d\u0435\u0446) deducing this, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043d\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 this \u0432 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0438\u043f\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u043e\u0439 &#171;\u043c\u0435\u0442\u043e\u0434&#187; \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439(\u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430), \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c(\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432) \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u041c\u0415\u0422\u041e\u0414 \u0432 \u044f\u0437\u044b\u043a\u0435 \u0421++(\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u044d\u0442\u0443 \u0432\u0435\u0449\u044c)  (\u043d\u0435 \u0434\u0430\u0439 \u0431\u043e\u0436\u0435 \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0434 \u0441\u043d\u043e\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043c\u0435\u0442\u043e\u0434)<\/p>\n<pre><code class=\"cpp\">struct A { void foo(this A&amp; self); };<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e this \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0435\u0436\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u043e\u0435 &#8212; \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u044f\u0432\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u0441\u044b\u043b\u043a\u0438\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451, \u043f\u043e\u043c\u0435\u0447\u0442\u0430\u043b\u0438 \u043e \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u043e\u043c hole C++, \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u0442\u0438 \u0438 \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0440\u0435\u043d\u044c \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0437\u0430\u0431\u044b\u0442\u044b\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u043d\u0430 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u043e\u043c \u0442\u0438\u043f\u0435 \u0438 \u0441\u0438\u0448\u043d\u044b\u043c\u0438 \u043a\u0430\u0441\u0442\u0430\u043c\u0438, \u0443\u0434\u0430\u0447\u0438&#8230; <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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\/672282\/\"> https:\/\/habr.com\/ru\/post\/672282\/<\/a><br \/><\/br><\/br><\/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-334714","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334714","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=334714"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334714\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}