{"id":379999,"date":"2024-06-26T15:01:09","date_gmt":"2024-06-26T15:01:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379999"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379999","title":{"rendered":"<span>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 ConditionalBitset \u2014 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/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<h2>\u0412\u0432\u043e\u0434\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/h2>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u0443 \u043c\u0435\u043d\u044f. \u0420\u0435\u0448\u0438\u043b \u0437\u0430\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u0411\u044b\u043b\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435. \u0418 \u0432 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e. \u0422\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u043e\u0441\u044c \u0447\u0435\u0440\u0435\u0437 \u0433\u0440\u0443\u043f\u043f\u0443 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0431\u0443\u043b\u0435\u0432\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0430\u0447\u043a\u0438. \u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0431\u0438\u0442\u0430\u0445 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<p><em>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b. \u0412\u0441\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u043d\u044b<\/em><\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442. \u041a\u0430\u043a-\u0442\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u044f \u0441 \u043a\u043e\u0434\u043e\u043c<\/p>\n<pre><code class=\"cpp\">bool hasFocus     { false }; bool hasWindow    { false }; bool isInitialized{ false }; bool isVisible    { false }; <\/code><\/pre>\n<p>\u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u043c\u0435\u043b \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">bool isActive() const {     return isInitialized &amp;&amp; hasFocus &amp;&amp; isVisible &amp;&amp; hasWindow; } <\/code><\/pre>\n<p><em>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 <\/em><code><em>constexpr<\/em><\/code><em> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440.<\/em><\/p>\n<p>\u0418 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u0435, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0430\u0447\u043a\u0443 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e. <code>isActive<\/code> \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0418 \u0442\u043e\u0436\u0435 \u0431\u0443\u043b\u0435\u0432\u043e. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 <code>isActive<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435, \u0433\u0434\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c 4. \u0414\u0430 \u0438 \u0442\u0435, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440. \u0423\u0441\u043b\u043e\u0432\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435. \u042f \u0432\u0438\u0434\u0435\u043b \u043a\u0430\u043a-\u0442\u043e \u043a\u043e\u0434 \u0441 12 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? \u0417\u0430\u043f\u0440\u0435\u0442\u043e\u0432 \u043a\u0430\u043a \u0431\u044b \u043d\u0435\u0442. \u041d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0410 \u043a\u0430\u043a \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b? \u0418 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0438\u0441\u0442\u0438\u043d\u0430 \u0432 <code>isActive<\/code> \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438 <code>hasFocus<\/code>, \u0438 <code>hasWindow<\/code>, \u0438 <code>isInitialized<\/code>, \u0438 <code>isVisible<\/code> \u0438\u0441\u0442\u0438\u043d\u044b? \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>setHasFocus<\/code>, <code>setHasWindow<\/code>, <code>seIsVisible<\/code> \u0438 <code>setIsInitialized<\/code>. \u0418 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u0441\u0435\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">void setHasFocus(bool value) {     hasFocus = value;     isActive = isInitialized &amp;&amp; hasFocus &amp;&amp; isVisible &amp;&amp; hasWindow; } <\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0418 \u043a\u0442\u043e-\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 \u00ab\u043f\u043e\u0433\u0430\u0441\u0438\u0442\u00bb \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. \u041d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::bitset \u044f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u0442\u043e. \u0412\u043e\u0442 \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443 std::bitset clang&#8217;\u0430:<\/p>\n<pre><code class=\"cpp\">__storage_type __first_[_N_words]; <\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0432\u0441\u0451. \u0421\u0442\u0430\u0440\u044b\u0435 \u0434\u043e\u0431\u0440\u044b\u0439 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e. \u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442? \u0411\u0435\u0440\u0451\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f, \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e <code>0<\/code> &#8212; \u044d\u0442\u043e \u0438\u0441\u0442\u0438\u043d\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0431\u0438\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441\u0442\u043e\u044f\u0442 \u0432 <code>0<\/code>, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0431\u0438\u0442, \u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b. \u041b\u043e\u0433\u0438\u0447\u043d\u043e? \u041b\u043e\u0433\u0438\u0447\u043d\u043e. \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0431\u0438\u0442\u044b &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0423\u0431\u0438\u0440\u0430\u044f \u0431\u0438\u0442\u044b &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f. \u0414\u0430\u0436\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u0438\u0442\u044b? \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D1%82%D0%B5%D0%BF%D0%B5%D0%BD%D1%8C_%D0%B4%D0%B2%D0%BE%D0%B9%D0%BA%D0%B8\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0432\u043e\u0439\u043a\u0438<\/a>, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%91%D0%B8%D1%82%D0%BE%D0%B2%D1%8B%D0%B9_%D1%81%D0%B4%D0%B2%D0%B8%D0%B3\" rel=\"noopener noreferrer nofollow\">\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433<\/a> \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D0%B5%D1%80%D0%B5%D1%87%D0%B8%D1%81%D0%BB%D1%8F%D0%B5%D0%BC%D1%8B%D0%B9_%D1%82%D0%B8%D0%BF\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<pre><code class=\"cpp\">enum class AppIsActiveConditions : uint8_t {     NONE        = 0,     INITIALIZED = (1 &lt;&lt; 0),     HAS_FOCUS   = (1 &lt;&lt; 1),     HAS_WINDOW  = (1 &lt;&lt; 2),     IS_VISIBLE  = (1 &lt;&lt; 3), }; <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0443\u0436\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <code>uint8_t<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043c\u0435\u0441\u0442\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 C++ \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f <code>int<\/code>. \u041c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439. \u0421\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437 &#8212; \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438\u043c\u0435\u043b\u0438 <strong><u>\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435<\/u><\/strong> \u0438 <strong><u>\u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f<\/u><\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 <code>NONE<\/code> \u0441 \u043d\u0443\u043b\u0451\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u041e\u043d\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u0442\u044c.<\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">ConditionalBitset &lt;AppIsActiveConditions> isActive {     AppIsActiveConditions::INITIALIZED,     AppIsActiveConditions::HAS_FOCUS,     AppIsActiveConditions::HAS_WINDOW,     AppIsActiveConditions::IS_VISIBLE }; <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>isActive<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0431\u0438\u0442\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u0418 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e <code>0<\/code>. \u0414\u0430\u043b\u0435\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438\u0441\u044c. \u0418\u043b\u0438 \u0437\u0430\u043d\u043e\u0432\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u043e \u0431\u044b\u0442\u044c \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<pre><code class=\"cpp\">isActive.reach(AppIsActiveConditions::INITIALIZED); \/\/ \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f isActive.lose(AppIsActiveConditions::INITIALIZED);  \/\/ \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 <\/code><\/pre>\n<p>\u041e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <code>true<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443. <code>false<\/code> \u0436\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>reach<\/code>, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043b\u0438\u0431\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e, \u043b\u0438\u0431\u043e \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>lose<\/code>, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0442\u0435\u0440\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043b\u0438\u0431\u043e \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e, \u043b\u0438\u0431\u043e \u0431\u044b\u043b\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0443\u043c\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434<\/p>\n<pre><code class=\"cpp\">isActive.isReached(AppIsActiveConditions::INITIALIZED); <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0431\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430.<br \/> (<strong>\u0421\u043f\u043e\u0439\u043b\u0435\u0440 \u0432 markdown \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0430\u043a, \u043f\u043e\u0440\u0442\u044f\u043d\u043a\u043e\u0439 &#8212; \u0434\u043b\u044f \u043e\u0431\u044a\u0451\u043c\u0443<\/strong>)<\/p>\n<h2>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430<\/h2>\n<pre><code class=\"cpp\">\/\/ \u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \/\/ \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u0432\u0432\u0435\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b.  \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f template &lt;typename Type, bool = std::is_enum&lt;Type>::value> class ConditionalBitset;  \/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0442\u0435\u043b\u043e \u043a\u043b\u0430\u0441\u0441\u0430 template &lt;typename EnumType> class ConditionalBitset &lt;EnumType, true> final {     \/\/ \u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f     using EnumUnderlyingType = typename std::underlying_type&lt;EnumType>::type;  public:     \/\/ \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u044e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440      template &lt;typename...Args>     explicit constexpr ConditionalBitset (Args&amp;&amp;...args) noexcept     {         ((add(std::forward&lt;Args>(args))),...);     }      \/\/ \u041f\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043a \u0431\u0443\u043b\u0435\u0432\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438     \/\/ \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0443\u043b\u0451\u043c \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c `!value`     constexpr operator bool() const noexcept { return value == 0; }      constexpr bool isReached(EnumType condition) const noexcept     {         return !has(condition);     }      constexpr bool lose(EnumType condition) noexcept     {         if (has(condition))         {             return false;         }          add(condition);         return true;     }      constexpr bool reach(EnumType condition) noexcept     {         if (!has(condition))         {             return false;         }          remove(condition);         return true;     }  private:     \/\/ \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u043e\u0436\u0435 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438      constexpr void add(EnumType condition) noexcept     {         value |= static_cast&lt;EnumUnderlyingType>(condition);     }      constexpr bool has(EnumType condition) const noexcept     {         return (value &amp; static_cast&lt;EnumUnderlyingType>(condition));     }      constexpr void remove(EnumType condition) noexcept     {         value ^= static_cast&lt;EnumUnderlyingType>(condition);     }      \/\/ \u0426\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u0430\u043a \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435     EnumUnderlyingType value;   }; <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e.<\/p>\n<h2>\u041c\u0438\u043d\u0443\u0441\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0418 \u0432 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u0438\u043d\u0443\u0441\u044b.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0438\u043d\u0443\u0441, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041d\u043e \u043c\u043d\u0435 \u044d\u0442\u043e \u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u044b\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439.<\/p>\n<p>\u041d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438\u0441\u044c, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0451 \u043d\u0435\u0442. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0443\u043c\u0435.<\/p>\n<p>\u0418 \u0435\u0449\u0451 &#8212; \u043d\u0435\u043b\u044c\u0437\u044f \u00ab\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u00bb \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0431\u043e \u00ab\u043f\u043e\u0433\u0430\u0441\u0438\u0442\u044c\u00bb \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u0434\u0435, \u043b\u0438\u0431\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435. \u042f \u0443\u043a\u0430\u0437\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c<\/p>\n<h2>Benchmarks<\/h2>\n<p>\u0418\u0445 \u043d\u0435\u0442. \u042d\u0442\u043e\u0442 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 &#8212; \u044d\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. \u0418 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f, \u043a\u0430\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430. \u0410 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043b\u044f \u0425\u0430\u0431\u0440\u0430 &#8212; \u0441\u0430\u043c\u043e\u0435 \u0442\u043e.<\/p>\n<hr\/>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/824812\/\"> https:\/\/habr.com\/ru\/articles\/824812\/<\/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<h2>\u0412\u0432\u043e\u0434\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/h2>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u0443 \u043c\u0435\u043d\u044f. \u0420\u0435\u0448\u0438\u043b \u0437\u0430\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u0411\u044b\u043b\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435. \u0418 \u0432 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e. \u0422\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u043e\u0441\u044c \u0447\u0435\u0440\u0435\u0437 \u0433\u0440\u0443\u043f\u043f\u0443 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0431\u0443\u043b\u0435\u0432\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0430\u0447\u043a\u0438. \u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0431\u0438\u0442\u0430\u0445 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<p><em>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b. \u0412\u0441\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u043d\u044b<\/em><\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442. \u041a\u0430\u043a-\u0442\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u044f \u0441 \u043a\u043e\u0434\u043e\u043c<\/p>\n<pre><code class=\"cpp\">bool hasFocus     { false }; bool hasWindow    { false }; bool isInitialized{ false }; bool isVisible    { false }; <\/code><\/pre>\n<p>\u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u043c\u0435\u043b \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">bool isActive() const {     return isInitialized &amp;&amp; hasFocus &amp;&amp; isVisible &amp;&amp; hasWindow; } <\/code><\/pre>\n<p><em>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 <\/em><code><em>constexpr<\/em><\/code><em> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440.<\/em><\/p>\n<p>\u0418 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u0435, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0430\u0447\u043a\u0443 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e. <code>isActive<\/code> \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0418 \u0442\u043e\u0436\u0435 \u0431\u0443\u043b\u0435\u0432\u043e. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 <code>isActive<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435, \u0433\u0434\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c 4. \u0414\u0430 \u0438 \u0442\u0435, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440. \u0423\u0441\u043b\u043e\u0432\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435. \u042f \u0432\u0438\u0434\u0435\u043b \u043a\u0430\u043a-\u0442\u043e \u043a\u043e\u0434 \u0441 12 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? \u0417\u0430\u043f\u0440\u0435\u0442\u043e\u0432 \u043a\u0430\u043a \u0431\u044b \u043d\u0435\u0442. \u041d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0410 \u043a\u0430\u043a \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b? \u0418 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0438\u0441\u0442\u0438\u043d\u0430 \u0432 <code>isActive<\/code> \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438 <code>hasFocus<\/code>, \u0438 <code>hasWindow<\/code>, \u0438 <code>isInitialized<\/code>, \u0438 <code>isVisible<\/code> \u0438\u0441\u0442\u0438\u043d\u044b? \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>setHasFocus<\/code>, <code>setHasWindow<\/code>, <code>seIsVisible<\/code> \u0438 <code>setIsInitialized<\/code>. \u0418 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u0441\u0435\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">void setHasFocus(bool value) {     hasFocus = value;     isActive = isInitialized &amp;&amp; hasFocus &amp;&amp; isVisible &amp;&amp; hasWindow; } <\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0418 \u043a\u0442\u043e-\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 \u00ab\u043f\u043e\u0433\u0430\u0441\u0438\u0442\u00bb \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. \u041d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::bitset \u044f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u0442\u043e. \u0412\u043e\u0442 \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443 std::bitset clang&#8217;\u0430:<\/p>\n<pre><code class=\"cpp\">__storage_type __first_[_N_words]; <\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0432\u0441\u0451. \u0421\u0442\u0430\u0440\u044b\u0435 \u0434\u043e\u0431\u0440\u044b\u0439 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e. \u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442? \u0411\u0435\u0440\u0451\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f, \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e <code>0<\/code> &#8212; \u044d\u0442\u043e \u0438\u0441\u0442\u0438\u043d\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0431\u0438\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441\u0442\u043e\u044f\u0442 \u0432 <code>0<\/code>, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0431\u0438\u0442, \u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b. \u041b\u043e\u0433\u0438\u0447\u043d\u043e? \u041b\u043e\u0433\u0438\u0447\u043d\u043e. \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0431\u0438\u0442\u044b &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0423\u0431\u0438\u0440\u0430\u044f \u0431\u0438\u0442\u044b &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f. \u0414\u0430\u0436\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u0438\u0442\u044b? \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D1%82%D0%B5%D0%BF%D0%B5%D0%BD%D1%8C_%D0%B4%D0%B2%D0%BE%D0%B9%D0%BA%D0%B8\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0432\u043e\u0439\u043a\u0438<\/a>, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%91%D0%B8%D1%82%D0%BE%D0%B2%D1%8B%D0%B9_%D1%81%D0%B4%D0%B2%D0%B8%D0%B3\" rel=\"noopener noreferrer nofollow\">\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433<\/a> \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D0%B5%D1%80%D0%B5%D1%87%D0%B8%D1%81%D0%BB%D1%8F%D0%B5%D0%BC%D1%8B%D0%B9_%D1%82%D0%B8%D0%BF\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<pre><code class=\"cpp\">enum class AppIsActiveConditions : uint8_t {     NONE        = 0,     INITIALIZED = (1 &lt;&lt; 0),     HAS_FOCUS   = (1 &lt;&lt; 1),     HAS_WINDOW  = (1 &lt;&lt; 2),     IS_VISIBLE  = (1 &lt;&lt; 3), }; <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0443\u0436\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <code>uint8_t<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043c\u0435\u0441\u0442\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 C++ \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f <code>int<\/code>. \u041c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439. \u0421\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437 &#8212; \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438\u043c\u0435\u043b\u0438 <strong><u>\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435<\/u><\/strong> \u0438 <strong><u>\u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f<\/u><\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 <code>NONE<\/code> \u0441 \u043d\u0443\u043b\u0451\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u041e\u043d\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u0442\u044c.<\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">ConditionalBitset &lt;AppIsActiveConditions> isActive {     AppIsActiveConditions::INITIALIZED,     AppIsActiveConditions::HAS_FOCUS,     AppIsActiveConditions::HAS_WINDOW,     AppIsActiveConditions::IS_VISIBLE }; <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>isActive<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0431\u0438\u0442\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u0418 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e <code>0<\/code>. \u0414\u0430\u043b\u0435\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438\u0441\u044c. \u0418\u043b\u0438 \u0437\u0430\u043d\u043e\u0432\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u043e \u0431\u044b\u0442\u044c \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<pre><code class=\"cpp\">isActive.reach(AppIsActiveConditions::INITIALIZED); \/\/ \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f isActive.lose(AppIsActiveConditions::INITIALIZED);  \/\/ \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 <\/code><\/pre>\n<p>\u041e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <code>true<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443. <code>false<\/code> \u0436\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>reach<\/code>, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043b\u0438\u0431\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e, \u043b\u0438\u0431\u043e \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>lose<\/code>, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0442\u0435\u0440\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f &#8212; \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043b\u0438\u0431\u043e \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e, \u043b\u0438\u0431\u043e \u0431\u044b\u043b\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0443\u043c\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434<\/p>\n<pre><code class=\"cpp\">isActive.isReached(AppIsActiveConditions::INITIALIZED); <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0431\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430.<br \/> (<strong>\u0421\u043f\u043e\u0439\u043b\u0435\u0440 \u0432 markdown \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0430\u043a, \u043f\u043e\u0440\u0442\u044f\u043d\u043a\u043e\u0439 &#8212; \u0434\u043b\u044f \u043e\u0431\u044a\u0451\u043c\u0443<\/strong>)<\/p>\n<h2>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430<\/h2>\n<pre><code class=\"cpp\">\/\/ \u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \/\/ \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u0432\u0432\u0435\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b.  \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f template &lt;typename Type, bool = std::is_enum&lt;Type>::value> class ConditionalBitset;  \/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0442\u0435\u043b\u043e \u043a\u043b\u0430\u0441\u0441\u0430 template &lt;typename EnumType> class ConditionalBitset &lt;EnumType, true> final {     \/\/ \u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f     using EnumUnderlyingType = typename std::underlying_type&lt;EnumType>::type;  public:     \/\/ \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u044e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440      template &lt;typename...Args>     explicit constexpr ConditionalBitset (Args&amp;&amp;...args) noexcept     {         ((add(std::forward&lt;Args>(args))),...);     }      \/\/ \u041f\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043a \u0431\u0443\u043b\u0435\u0432\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438     \/\/ \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0443\u043b\u0451\u043c \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c `!value`     constexpr operator bool() const noexcept { return value == 0; }      constexpr bool isReached(EnumType condition) const noexcept     {         return !has(condition);     }      constexpr bool lose(EnumType condition) noexcept     {         if (has(condition))         {             return false;         }          add(condition);         return true;     }      constexpr bool reach(EnumType condition) noexcept     {         if (!has(condition))         {             return false;         }          remove(condition);         return true;     }  private:     \/\/ \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u043e\u0436\u0435 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438      constexpr void add(EnumType condition) noexcept     {         value |= static_cast&lt;EnumUnderlyingType>(condition);     }      constexpr bool has(EnumType condition) const noexcept     {         return (value &amp; static_cast&lt;EnumUnderlyingType>(condition));     }      constexpr void remove(EnumType condition) noexcept     {         value ^= static_cast&lt;EnumUnderlyingType>(condition);     }      \/\/ \u0426\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u0430\u043a \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435     EnumUnderlyingType value;   }; <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e.<\/p>\n<h2>\u041c\u0438\u043d\u0443\u0441\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0418 \u0432 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u0438\u043d\u0443\u0441\u044b.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0438\u043d\u0443\u0441, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041d\u043e \u043c\u043d\u0435 \u044d\u0442\u043e \u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u044b\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439.<\/p>\n<p>\u041d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438\u0441\u044c, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0451 \u043d\u0435\u0442. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0443\u043c\u0435.<\/p>\n<p>\u0418 \u0435\u0449\u0451 &#8212; \u043d\u0435\u043b\u044c\u0437\u044f \u00ab\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u00bb \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0431\u043e \u00ab\u043f\u043e\u0433\u0430\u0441\u0438\u0442\u044c\u00bb \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u0434\u0435, \u043b\u0438\u0431\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435. \u042f \u0443\u043a\u0430\u0437\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c<\/p>\n<h2>Benchmarks<\/h2>\n<p>\u0418\u0445 \u043d\u0435\u0442. \u042d\u0442\u043e\u0442 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 &#8212; \u044d\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. \u0418 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f, \u043a\u0430\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430. \u0410 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043b\u044f \u0425\u0430\u0431\u0440\u0430 &#8212; \u0441\u0430\u043c\u043e\u0435 \u0442\u043e.<\/p>\n<hr\/>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/824812\/\"> https:\/\/habr.com\/ru\/articles\/824812\/<\/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-379999","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379999","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=379999"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379999\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}