{"id":485296,"date":"2026-06-28T04:10:24","date_gmt":"2026-06-28T04:10:24","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=485296"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=485296","title":{"rendered":"\u0428\u0430\u0431\u043b\u043e\u043d\u044b C++ \u043a\u0430\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: compile-time dispatch, type traits \u0438 type erasure"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e! \u042f \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043c\u043e\u0432\u0435\u0442\u043e\u043d, \u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043a\u043e\u0434. \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u0442\u044f\u0436\u0451\u043b\u044b\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u0441\u0430\u043c\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435, \u0430 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0432 C++ &#8212; \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e std::vector \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u043c C++ \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0437 runtime \u0432 compile-time, \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432, \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 runtime-\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>\u0413\u0434\u0435 \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e<\/strong><\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c:<\/p>\n<blockquote>\n<p><em><u>\u041c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0434\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/u><\/em><\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0438\u043b\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0442\u0430\u043a \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0438, \u0433\u0434\u0435 compile-time \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432, \u0430 \u043d\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>struct EventA {    std::uint64_t count = 0;    double value = 0.0;};struct EventB {    std::uint64_t count = 0;    double value = 0.0;    double rate = 0.0;};struct EventC {    std::uint64_t count = 0;    double value = 0.0;    std::string label;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0423 \u0432\u0441\u0435\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0435\u0441\u0442\u044c <strong>count<\/strong> \u0438 <strong>value<\/strong>, \u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 enum, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f\u0445. \u0412 \u0434\u043e\u0431\u0430\u0432\u043e\u043a \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f\u044b, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0430\u043c \u043d\u0430\u0447\u043d\u0451\u0442 \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043e\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p><strong>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/strong><\/p>\n<pre><code>template &lt;typename Event&gt; void process(const Event&amp; event) { std::cout &lt;&lt; event.count &lt;&lt; std::endl;  std::cout &lt;&lt; event.value &lt;&lt; std::endl;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e <strong>Event<\/strong>, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0432\u043e\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041e\u043d \u0432\u0438\u0434\u0438\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a:<\/p>\n<pre><code>void process(const EventA&amp; event);void process(const EventB&amp; event);void process(const EventC&amp; event);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0443 \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u0449\u0430\u044f, \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0451 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u043d\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p><strong>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b compile-time \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b<\/strong><\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0448\u0435 <strong><em>template  void process(const Event&amp; event)<\/em><\/strong> \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0438\u043f\u0443. \u041e\u043d\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f <strong>count<\/strong> \u0438 <strong>value<\/strong>.<\/p>\n<p>\u0412 \u0421++20 \u043d\u0430\u043c \u0437\u0430\u0432\u0435\u0437\u043b\u0438 concept \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u043c \u044d\u0442\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u044f\u0432\u043d\u043e:<\/p>\n<pre><code>template &lt;typename T&gt; concept BasicEvent = requires(T&amp; event) { { event.count } -&gt; std::convertible_to&lt;std::uint64_t&gt;; { event.value } -&gt; std::convertible_to&lt;double&gt;; };<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:<\/p>\n<pre><code>template &lt;BasicEvent Event&gt; void process(const Event&amp; event) { std::cout &lt;&lt; \"count = \" &lt;&lt; event.count &lt;&lt; std::endl;std::cout &lt;&lt; \"value = \" &lt;&lt; event.value &lt;&lt; std::endl; }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u0442\u0443\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438!<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430  <strong>EventA<\/strong> \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <strong>count<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a <strong>std::uint64_t<\/strong> \u0438 \u043f\u043e\u043b\u0435 <strong>value<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a <strong>double<\/strong>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u0434\u043b\u044f EventA:<\/p>\n<pre><code>template &lt;typename T&gt;concept BasicEvent = requires(T event) {    { event.count } -&gt; std::convertible_to&lt;std::string&gt;;    { event.value } -&gt; std::convertible_to&lt;double&gt;;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b <strong>event.count<\/strong> \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 <strong>\u043a std::string<\/strong>. \u041d\u043e \u0432 <strong>EventA<\/strong> \u043f\u043e\u043b\u0435 <strong>count<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <strong>std::uint64_t<\/strong>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0438\u043f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 <strong>BasicEvent<\/strong>.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code>EventA a;process(a);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code>.\/m.cpp: In function \u2018int main()\u2019:.\/m.cpp:40:17: error: no matching function for call to \u2018process(EventA&amp;)\u2019   40 |     process(a);      |     ~~~~~~~~~~~~^~~.\/m.cpp:31:34: note: candidate: \u2018template&lt;class Event&gt;  requires  BasicEvent&lt;Event&gt; void process(const Event&amp;)\u2019   31 | template &lt;BasicEvent Event&gt; void process(const Event &amp;event)      |                                  ^~~~~~~~~~~~.\/m.cpp:31:34: note:   template argument deduction\/substitution failed:.\/m.cpp:31:34: note: constraints not satisfied.\/m.cpp: In substitution of \u2018template&lt;class Event&gt;  requires  BasicEvent&lt;Event&gt; void process(const Event&amp;) [with Event = EventA]\u2019:.\/m.cpp:40:17:   required from here.\/m.cpp:26:9:   required for the satisfaction of \u2018BasicEvent&lt;Event&gt;\u2019 [with Event = EventA].\/m.cpp:26:22:   in requirements with \u2018T event\u2019 [with T = EventA].\/m.cpp:27:13: note: \u2018event.count\u2019 does not satisfy return-type-requirement   27 |     { event.count } -&gt; std::convertible_to&lt;std::string&gt;;      |       ~~~~~~^~~~~cc1plus: note: set \u2018-fconcepts-diagnostics-depth=\u2019 to at least 2 for more detail<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0440\u0430\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b <strong>concept<\/strong>, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0433\u0434\u0435-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c. \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0438\u043f <strong>EventA<\/strong> \u043d\u0435 \u043f\u0440\u043e\u0448\u0451\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 <strong>BasicEvent<\/strong>.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0434\u0435\u0441\u044c:<\/p>\n<pre><code>{ event.count } -&gt; std::convertible_to&lt;std::string&gt;;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <strong>event.count<\/strong> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0435\u0433\u043e \u0442\u0438\u043f \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e. \u041c\u044b \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 <strong>std::string<\/strong>, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <strong>std::uint64_t<\/strong><\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0438\u043f\u0443 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<p><strong>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0433\u043e <strong>if<\/strong>, <strong>switch<\/strong> \u0438 enum-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439, \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0441\u0438\u0433\u043d\u0430\u043b, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 policy-\u0442\u0438\u043f\u044b.<\/p>\n<pre><code>template &lt;typename FilterPolicy, typename ScorePolicy, typename ExportPolicy&gt;class Pipeline {public:    void process(double value) {        if (!filter_.accept(value)) {            return;        }        auto result = score_.calculate(value);        if (result.active) {            export_.send(result);        }    }private:    FilterPolicy filter_;    ScorePolicy score_;    ExportPolicy export_;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code>using DebugPipeline = Pipeline&lt;ThresholdFilter,SimpleScore,ConsoleExport&gt;;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 runtime-\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c pipeline \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<h3>Compile-time dispatch \u0447\u0435\u0440\u0435\u0437 if constexpr<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440-\u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043f\u043e\u043b\u044f <strong>count<\/strong> \u0438 <strong>value<\/strong>, \u043d\u043e \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 <strong>EventB<\/strong> \u0435\u0441\u0442\u044c <strong>rate<\/strong>, \u0430 \u0443 <strong>EventC<\/strong> \u0435\u0441\u0442\u044c <strong>label<\/strong>.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u0442\u043e \u043a \u043d\u0430\u043c \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c <strong>if constexpr \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 std::is_same_v&lt;&gt;<\/strong><\/p>\n<pre><code>template &lt;typename Event&gt; void process_event(const Event &amp;event){    std::cout &lt;&lt; \"count = \" &lt;&lt; event.count &lt;&lt; std::endl;    std::cout &lt;&lt; \"value = \" &lt;&lt; event.value &lt;&lt; std::endl;    if constexpr (std::is_same_v&lt;Event, EventB&gt;)    {        std::cout &lt;&lt; \"rate = \" &lt;&lt; event.rate &lt;&lt; std::endl;    }    else if constexpr (std::is_same_v&lt;Event, EventC&gt;)    {        std::cout &lt;&lt; \"label = \" &lt;&lt; event.label &lt;&lt; std::endl;    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <strong>if constexpr (std::is_same_v&lt;&gt;)<\/strong> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 <strong>Event<\/strong> &#8212; \u044d\u0442\u043e <strong>EventB<\/strong>, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u0435\u0442\u043a\u0443 \u0441 <strong>rate<\/strong>.<br \/> \u0415\u0441\u043b\u0438 <strong>Event<\/strong> &#8212; \u044d\u0442\u043e <strong>EventC<\/strong>, \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u0435\u0442\u043a\u0443 \u0441 <strong>label<\/strong>. <br \/> \u0410 \u0434\u043b\u044f <strong>EventA<\/strong> \u043e\u0431\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0442\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0431\u0440\u043e\u0448\u0435\u043d\u044b.<\/p>\n<p>\u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0441\u0430\u0445\u0430\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0434\u043d\u0443 \u043e\u0431\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<p>\u0412 runtime-\u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <strong>switch<\/strong>, enum \u0438\u043b\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 compile-time-\u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/p>\n<h2>Type traits<\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<p>std::is_same_v&lt;Event, EventB&gt;<\/p>\n<p>\u0414\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041a\u043e\u0434 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439, \u0442\u0438\u043f\u043e\u0432 \u043c\u0430\u043b\u043e, \u0432\u0441\u0451 \u043b\u0435\u0433\u043a\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u0442\u0451\u0442, \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043a\u043e\u0434. \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432\u0438\u0434\u0430: \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventB\u00bb, \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventC\u00bb, \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventD\u00bb. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <strong>traits<\/strong>:<\/p>\n<pre><code>template &lt;typename Event&gt; struct event_traits;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0441\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<pre><code>template &lt;&gt; struct event_traits&lt;EventA&gt;{    static constexpr std::string_view name = \"event_a\";    static constexpr bool has_rate = false;    static constexpr bool has_label = false;};template &lt;&gt; struct event_traits&lt;EventB&gt;{    static constexpr std::string_view name = \"event_b\";    static constexpr bool has_rate = true;    static constexpr bool has_label = false;};template &lt;&gt; struct event_traits&lt;EventC&gt;{    static constexpr std::string_view name = \"event_c\";    static constexpr bool has_rate = false;    static constexpr bool has_label = true;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0443\u0442\u044c \u0447\u0438\u0449\u0435:<\/p>\n<pre><code>template &lt;typename Event&gt; void process_v2(const Event &amp;event){    using traits = event_traits&lt;Event&gt;;    std::cout &lt;&lt; \"type = \" &lt;&lt; traits::name &lt;&lt; '\\n';    std::cout &lt;&lt; \"count = \" &lt;&lt; event.count &lt;&lt; '\\n';    std::cout &lt;&lt; \"value = \" &lt;&lt; event.value &lt;&lt; '\\n';    if constexpr (traits::has_rate)    {        std::cout &lt;&lt; \"rate = \" &lt;&lt; event.rate &lt;&lt; '\\n';    }    if constexpr (traits::has_label)    {        std::cout &lt;&lt; \"label = \" &lt;&lt; event.label &lt;&lt; '\\n';    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a <strong>EventB<\/strong> \u0438\u043b\u0438 <strong>EventC<\/strong>. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0430 \u0441 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<p>\u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0433\u0438\u0431\u0447\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<pre><code>struct EventD {    std::uint64_t count = 0;    double value = 0.0;    double rate = 0.0;    double deviation = 0.0;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code>template &lt;&gt;struct event_traits&lt;EventD&gt; {    static constexpr std::string_view name = \"event_d\";    static constexpr bool has_rate = true;    static constexpr bool has_label = false;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u043e\u0431\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h2>Type erasure<\/h2>\n<p>\u042d\u0442\u043e \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 template \u0438 virtual. \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0445\u043e\u0440\u043e\u0448\u0438, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438\u043b\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 runtime. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code>struct IProcessor {    virtual void process(double value) = 0;    virtual ~IProcessor() = default;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 &#8212; type erasure, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u0430 \u0435\u0434\u0438\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0441\u0430\u043c \u0442\u0438\u043f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>class AnyProcessor{  public:    template &lt;typename Processor&gt;    AnyProcessor(Processor processor) : object_(std::make_shared&lt;Model&lt;Processor&gt;&gt;(std::move(processor))){}    void process(double value) { object_-&gt;process(value); }  private:    struct Concept    {        virtual void process(double value) = 0;        virtual ~Concept() = default;    };    template &lt;typename Processor&gt;     struct Model final : Concept    {        explicit Model(Processor processor) : processor_(std::move(processor)) {}        void process(double value) override { processor_.process(value); }        Processor processor_;    };    std::shared_ptr&lt;Concept&gt; object_;};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code>struct LoggingProcessor{    void process(double value) { std::cout &lt;&lt; \"value = \" &lt;&lt; value &lt;&lt; std::endl; }};struct CountingProcessor{    std::size_t count = 0;    void process(double) { ++count; }};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e:<\/p>\n<pre><code>std::vector&lt;AnyProcessor&gt; processors;processors.emplace_back(LoggingProcessor{});processors.emplace_back(CountingProcessor{});for (auto&amp; processor : processors) {    processor.process(42.0);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0442\u0440\u0443\u0434\u043d\u044b\u043c, \u043d\u043e \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e:<\/p>\n<ul>\n<li>\n<p>LoggingProcessor \u0438 CountingProcessor \u043d\u0435 \u0437\u043d\u0430\u044e\u0442 \u043f\u0440\u043e AnyProcessor<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043e\u0431\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0435\u0434\u0438\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c AnyProcessor<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f runtime dispatch, \u043d\u043e \u043e\u043d \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d<\/p>\n<\/li>\n<\/ul>\n<h2>\u041a\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 virtual, \u043a\u043e\u0433\u0434\u0430 template, \u0430 \u043a\u043e\u0433\u0434\u0430 type erasure<\/h2>\n<p><strong>Type erasure<\/strong> \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043c\u0435\u0441\u0442, \u0433\u0434\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043f\u043b\u0430\u0433\u0438\u043d\u044b, \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 API.<\/p>\n<p>\u041d\u043e \u0432\u043d\u0443\u0442\u0440\u0438, \u0433\u0434\u0435 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u0438 \u0432\u0430\u0436\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b. \u0422\u0430\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0438\u0434\u0438\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438 \u043c\u043e\u0436\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0443\u043c\u0435\u0441\u0442\u0435\u043d.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0434\u0430\u044e\u0442 compile-time polymorphism(\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c): \u0442\u0438\u043f \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439.<\/p>\n<p>\u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0430\u044e\u0442 runtime polymorphism(\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c): \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p><strong>Type erasure<\/strong> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u041e\u043d \u0442\u043e\u0436\u0435 \u0434\u0430\u0451\u0442 runtime-\u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u044f\u0447\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u0430 \u043e\u0431\u0449\u0435\u0439 \u043e\u0431\u0451\u0440\u0442\u043a\u043e\u0439.<\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e:<br \/> <strong><em>template<\/em><\/strong>  &#8212; \u0432\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u0432 compile-time, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<br \/> <strong><em>virtual<\/em><\/strong>  &#8212;     \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 runtime \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<br \/> <strong><em>type erasure<\/em><\/strong>  &#8212; runtime-\u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0431\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u0430\u0445<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a: \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u043e\u0440\u044f\u0447\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u2014 \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u043d\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0445 runtime-\u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u2014 <strong>virtual<\/strong>, \u0430 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f runtime-\u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0431\u0435\u0437 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u2014 <strong>type erasure<\/strong>.<\/p>\n<p><strong>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433:<\/strong><br \/> \u041c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 C++ \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u0432\u0435\u0442\u043e\u043d, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0434\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u0433\u0434\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430, \u043a\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0430 \u043d\u0435 \u043b\u0443\u0447\u0448\u0435.<\/p>\n<p>\u041d\u043e \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0440\u0435\u0448\u0430\u044e\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0443\u0431\u0440\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 runtime-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0438\u043f\u0430\u043c \u0447\u0435\u0440\u0435\u0437 concepts, \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 policy-\u0442\u0438\u043f\u043e\u0432 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 \u043f\u043e\u0442\u0435\u0440\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0441\u043f\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0435\u0441\u0442\u044c \u0446\u0435\u043d\u0430, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a, \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0438 \u0442.\u0434. <br \/> \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u0442\u043e\u0438\u0442 \u043d\u0435 \u0432\u0435\u0437\u0434\u0435, \u0430 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0442\u0438\u043f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u0451\u0442 \u0441\u043c\u044b\u0441\u043b.<\/p>\n<div class=\"persona\"><img decoding=\"async\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/avatars\/5cc\/a4d\/bbb\/5cca4dbbb88b5d6179f9827487a0cbba.jpg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/avatars\/5cc\/a4d\/bbb\/5cca4dbbb88b5d6179f9827487a0cbba.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/avatars\/5cc\/a4d\/bbb\/5cca4dbbb88b5d6179f9827487a0cbba.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<h5 class=\"persona__heading\">\u0416\u0443\u043a\u043e\u0432 \u041c\u0430\u0442\u0432\u0435\u0439 \/\u041d\u0418\u0423 \u041c\u042d\u0418 \u0418\u0412\u0422\u0418 \/\u041a\u0430\u0444\u0435\u0434\u0440\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439<\/h5>\n<p class=\"persona__text\"><em>C++ \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/em><\/p>\n<\/div>\n<\/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=\"https:\/\/habr.com\/ru\/articles\/1052788\/\">https:\/\/habr.com\/ru\/articles\/1052788\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0441\u0435\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e! \u042f \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043c\u043e\u0432\u0435\u0442\u043e\u043d, \u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043a\u043e\u0434. \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u0442\u044f\u0436\u0451\u043b\u044b\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f.\u041d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u0441\u0430\u043c\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435, \u0430 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442.\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0432 C++ &#8212; \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e std::vector \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u043c C++ \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0437 runtime \u0432 compile-time, \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432, \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 runtime-\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438.\u0413\u0434\u0435 \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e\u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c:\u041c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0434\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0438\u043b\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0442\u0430\u043a \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c.\u041d\u043e \u0435\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0438, \u0433\u0434\u0435 compile-time \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d.\u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432, \u0430 \u043d\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:struct EventA {    std::uint64_t count = 0;    double value = 0.0;};struct EventB {    std::uint64_t count = 0;    double value = 0.0;    double rate = 0.0;};struct EventC {    std::uint64_t count = 0;    double value = 0.0;    std::string label;};\u0423 \u0432\u0441\u0435\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0435\u0441\u0442\u044c count \u0438 value, \u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 enum, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f\u0445. \u0412 \u0434\u043e\u0431\u0430\u0432\u043e\u043a \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f\u044b, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0430\u043c \u043d\u0430\u0447\u043d\u0451\u0442 \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043e\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439.\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432template &lt;typename Event&gt; void process(const Event&amp; event) { std::cout &lt;&lt; event.count &lt;&lt; std::endl;  std::cout &lt;&lt; event.value &lt;&lt; std::endl;}\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e Event, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0432\u043e\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041e\u043d \u0432\u0438\u0434\u0438\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a:void process(const EventA&amp; event);void process(const EventB&amp; event);void process(const EventC&amp; event);\u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0443 \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u0449\u0430\u044f, \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0451 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u043d\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b compile-time \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0448\u0435 template  void process(const Event&amp; event) \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0438\u043f\u0443. \u041e\u043d\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f count \u0438 value.\u0412 \u0421++20 \u043d\u0430\u043c \u0437\u0430\u0432\u0435\u0437\u043b\u0438 concept \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u043c \u044d\u0442\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u044f\u0432\u043d\u043e:template &lt;typename T&gt; concept BasicEvent = requires(T&amp; event) { { event.count } -&gt; std::convertible_to&lt;std::uint64_t&gt;; { event.value } -&gt; std::convertible_to&lt;double&gt;; };\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:template &lt;BasicEvent Event&gt; void process(const Event&amp; event) { std::cout &lt;&lt; &#171;count = &#187; &lt;&lt; event.count &lt;&lt; std::endl;std::cout &lt;&lt; &#171;value = &#187; &lt;&lt; event.value &lt;&lt; std::endl; }\u0418 \u0442\u0443\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438!\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430  EventA \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 count, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a std::uint64_t \u0438 \u043f\u043e\u043b\u0435 value, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a double.\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u0434\u043b\u044f EventA:template &lt;typename T&gt;concept BasicEvent = requires(T event) {    { event.count } -&gt; std::convertible_to&lt;std::string&gt;;    { event.value } -&gt; std::convertible_to&lt;double&gt;;};\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b event.count \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a std::string. \u041d\u043e \u0432 EventA \u043f\u043e\u043b\u0435 count \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f std::uint64_t, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0438\u043f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 BasicEvent.\u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e:EventA a;process(a);\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443:.\/m.cpp: In function \u2018int main()\u2019:.\/m.cpp:40:17: error: no matching function for call to \u2018process(EventA&amp;)\u2019   40 |     process(a);      |     ~~~~~~~~~~~~^~~.\/m.cpp:31:34: note: candidate: \u2018template&lt;class Event&gt;  requires  BasicEvent&lt;Event&gt; void process(const Event&amp;)\u2019   31 | template &lt;BasicEvent Event&gt; void process(const Event &amp;event)      |                                  ^~~~~~~~~~~~.\/m.cpp:31:34: note:   template argument deduction\/substitution failed:.\/m.cpp:31:34: note: constraints not satisfied.\/m.cpp: In substitution of \u2018template&lt;class Event&gt;  requires  BasicEvent&lt;Event&gt; void process(const Event&amp;) [with Event = EventA]\u2019:.\/m.cpp:40:17:   required from here.\/m.cpp:26:9:   required for the satisfaction of \u2018BasicEvent&lt;Event&gt;\u2019 [with Event = EventA].\/m.cpp:26:22:   in requirements with \u2018T event\u2019 [with T = EventA].\/m.cpp:27:13: note: \u2018event.count\u2019 does not satisfy return-type-requirement   27 |     { event.count } -&gt; std::convertible_to&lt;std::string&gt;;      |       ~~~~~~^~~~~cc1plus: note: set \u2018-fconcepts-diagnostics-depth=\u2019 to at least 2 for more detail\u0418 \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0440\u0430\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b concept, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0433\u0434\u0435-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c. \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0438\u043f EventA \u043d\u0435 \u043f\u0440\u043e\u0448\u0451\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 BasicEvent.\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0434\u0435\u0441\u044c:{ event.count } -&gt; std::convertible_to&lt;std::string&gt;;\u0422\u043e \u0435\u0441\u0442\u044c event.count \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0435\u0433\u043e \u0442\u0438\u043f \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e. \u041c\u044b \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 std::string, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 std::uint64_t\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0438\u043f\u0443 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438\u0415\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0433\u043e if, switch \u0438 enum-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439, \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0441\u0438\u0433\u043d\u0430\u043b, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 policy-\u0442\u0438\u043f\u044b.template &lt;typename FilterPolicy, typename ScorePolicy, typename ExportPolicy&gt;class Pipeline {public:    void process(double value) {        if (!filter_.accept(value)) {            return;        }        auto result = score_.calculate(value);        if (result.active) {            export_.send(result);        }    }private:    FilterPolicy filter_;    ScorePolicy score_;    ExportPolicy export_;};\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:using DebugPipeline = Pipeline&lt;ThresholdFilter,SimpleScore,ConsoleExport&gt;;\u0412\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 runtime-\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c pipeline \u0446\u0435\u043b\u0438\u043a\u043e\u043c.Compile-time dispatch \u0447\u0435\u0440\u0435\u0437 if constexpr\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440-\u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043f\u043e\u043b\u044f count \u0438 value, \u043d\u043e \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 EventB \u0435\u0441\u0442\u044c rate, \u0430 \u0443 EventC \u0435\u0441\u0442\u044c label.\u0412\u043e\u0442 \u0442\u0443\u0442 \u0442\u043e \u043a \u043d\u0430\u043c \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c if constexpr \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 std::is_same_v&lt;&gt;template &lt;typename Event&gt; void process_event(const Event &amp;event){    std::cout &lt;&lt; &#171;count = &#187; &lt;&lt; event.count &lt;&lt; std::endl;    std::cout &lt;&lt; &#171;value = &#187; &lt;&lt; event.value &lt;&lt; std::endl;    if constexpr (std::is_same_v&lt;Event, EventB&gt;)    {        std::cout &lt;&lt; &#171;rate = &#187; &lt;&lt; event.rate &lt;&lt; std::endl;    }    else if constexpr (std::is_same_v&lt;Event, EventC&gt;)    {        std::cout &lt;&lt; &#171;label = &#187; &lt;&lt; event.label &lt;&lt; std::endl;    }}\u0417\u0434\u0435\u0441\u044c if constexpr (std::is_same_v&lt;&gt;) \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.\u0415\u0441\u043b\u0438 Event &#8212; \u044d\u0442\u043e EventB, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u0435\u0442\u043a\u0443 \u0441 rate. \u0415\u0441\u043b\u0438 Event &#8212; \u044d\u0442\u043e EventC, \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u0435\u0442\u043a\u0443 \u0441 label.  \u0410 \u0434\u043b\u044f EventA \u043e\u0431\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0442\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0431\u0440\u043e\u0448\u0435\u043d\u044b.\u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0441\u0430\u0445\u0430\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0434\u043d\u0443 \u043e\u0431\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b.\u0412 runtime-\u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 switch, enum \u0438\u043b\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 compile-time-\u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430.Type traits\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:std::is_same_v&lt;Event, EventB&gt;\u0414\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041a\u043e\u0434 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439, \u0442\u0438\u043f\u043e\u0432 \u043c\u0430\u043b\u043e, \u0432\u0441\u0451 \u043b\u0435\u0433\u043a\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435.\u041d\u043e \u0435\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u0442\u0451\u0442, \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043a\u043e\u0434. \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432\u0438\u0434\u0430: \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventB\u00bb, \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventC\u00bb, \u00ab\u0435\u0441\u043b\u0438 \u044d\u0442\u043e EventD\u00bb. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445.\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 traits:template &lt;typename Event&gt; struct event_traits;\u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0441\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f:template &lt;&gt; struct event_traits&lt;EventA&gt;{    static constexpr std::string_view name = &#171;event_a&#187;;    static constexpr bool has_rate = false;    static constexpr bool has_label = false;};template &lt;&gt; struct event_traits&lt;EventB&gt;{    static constexpr std::string_view name = &#171;event_b&#187;;    static constexpr bool has_rate = true;    static constexpr bool has_label = false;};template &lt;&gt; struct event_traits&lt;EventC&gt;{    static constexpr std::string_view name = &#171;event_c&#187;;    static constexpr bool has_rate = false;    static constexpr bool has_label = true;};\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0443\u0442\u044c \u0447\u0438\u0449\u0435:template &lt;typename Event&gt; void process_v2(const Event &amp;event){    using traits = event_traits&lt;Event&gt;;    std::cout &lt;&lt; &#171;type = &#187; &lt;&lt; traits::name &lt;&lt; &#8216;\\n&#8217;;    std::cout &lt;&lt; &#171;count = &#187; &lt;&lt; event.count &lt;&lt; &#8216;\\n&#8217;;    std::cout &lt;&lt; &#171;value = &#187; &lt;&lt; event.value &lt;&lt; &#8216;\\n&#8217;;    if constexpr (traits::has_rate)    {        std::cout &lt;&lt; &#171;rate = &#187; &lt;&lt; event.rate &lt;&lt; &#8216;\\n&#8217;;    }    if constexpr (traits::has_label)    {        std::cout &lt;&lt; &#171;label = &#187; &lt;&lt; event.label &lt;&lt; &#8216;\\n&#8217;;    }}\u0417\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a EventB \u0438\u043b\u0438 EventC. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0430 \u0441 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.\u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0433\u0438\u0431\u0447\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f:struct EventD {    std::uint64_t count = 0;    double value = 0.0;    double rate = 0.0;    double deviation =&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-485296","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485296","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=485296"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485296\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}