{"id":277305,"date":"2016-03-30T16:39:02","date_gmt":"2016-03-30T12:39:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=277305"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=277305","title":{"rendered":"\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b C++"},"content":{"rendered":"<p>       \u0412 \u0441\u0432\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 C++, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u00ab\u0434\u0435\u0441\u044f\u0442\u043a\u0443\u00bb (char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long) \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0432\u0438\u043d\u0434\u043e\u0432\u044b\u0445 DWORD, __int64 \u0438 \u0442.\u043f. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0438\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043c\u0435\u043d\u043d\u043e 4 \u0431\u0430\u0439\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0447\u043d\u043e 4, \u0430 \u043d\u0435 \u00ab\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e\u00bb, \u00ab\u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0434\u0440\u0435\u0441\u0430\u00bb \u0438 \u0442.\u043f. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++ \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u043b\u0438\u0448\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u0440\u0430\u0441\u043f\u0435\u0432: char \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 short, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 int, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 long, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 long long. <\/p>\n<p>  \u041f\u0440\u0438\u043e\u0431\u0449\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u043c\u0430\u0433\u0438\u0438 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0440\u0435\u0448\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u2014 \u044d\u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0444\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u00ab\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439\u00bb \u0442\u0438\u043f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d type_traits:<\/p>\n<pre><code class=\"cpp\">    template&lt;typename type&gt; struct type_traits;     template&lt;&gt; struct type_traits &lt;unsigned char&gt; { typedef unsigned char current_type; typedef unsigned short next_type; };     template&lt;&gt; struct type_traits &lt;unsigned short&gt; { typedef unsigned short current_type; typedef unsigned int next_type; };     template&lt;&gt; struct type_traits &lt;unsigned int&gt; { typedef unsigned int current_type; typedef unsigned long next_type; };     template&lt;&gt; struct type_traits &lt;unsigned long&gt; {\ttypedef unsigned long current_type; typedef unsigned long long next_type; };     template&lt;&gt; struct type_traits &lt;unsigned long long&gt; { typedef unsigned long long current_type; };     template&lt;&gt; struct type_traits &lt;char&gt; { typedef char current_type; typedef short next_type; };     template&lt;&gt; struct type_traits &lt;short&gt; { typedef short current_type; typedef int next_type; };     template&lt;&gt; struct type_traits &lt;int&gt; { typedef int current_type; typedef long next_type; };     template&lt;&gt; struct type_traits &lt;long&gt; { typedef long current_type; typedef long long next_type; };     template&lt;&gt; struct type_traits &lt;long long&gt; { typedef long long current_type;}; <\/code><\/pre>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432 (unsigned) long long \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e next_type \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0445 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u0431\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: type \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0442\u0438\u043f \u0438 bool&#8217;\u0435\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u0430 true, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0438\u043b\u0438 false \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442. \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0435\u0440\u0451\u043c \u0443 type \u00ab\u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u0438\u043f\u00bb \u2014 type_traits::current_type, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u0431\u0435\u0440\u0451\u043c \u00ab\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439\u00bb \u2014 type_traits::next_type:<\/p>\n<pre><code class=\"cpp\">\/\/ \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u0438\u043f\u0430     template&lt;typename type, bool&gt;      struct type_choice      {          typedef typename type_traits&lt;type&gt;::current_type std_type;      };     template&lt;typename type&gt;      struct type_choice&lt;type, false&gt;      {          typedef typename type_traits&lt;type&gt;::next_type next_type;          typedef typename type_choice&lt;next_type, sizeof(next_type) == capacity&gt;::std_type std_type;      }; <\/code><\/pre>\n<p>  \u0422\u0440\u0435\u0442\u0438\u0439 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043d\u0430\u0441 \u0434\u0432\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0445\u043e\u0442\u0438\u043c \u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0438\u043b\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u2014 char \u0438\u043b\u0438 unsigned char:<\/p>\n<pre><code class=\"cpp\">    \/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u0431\u043e\u0440\u0430     template &lt;bool is_signed&gt; struct base_type_selector { typedef char base_type; };     template &lt;&gt; struct base_type_selector&lt;false&gt; { typedef unsigned char base_type; }; <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f. \u042f \u043d\u0430\u0437\u0432\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 fixed_int, \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f size_t \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0451\u043c\u043a\u043e\u0441\u0442\u044c \u0432 \u0431\u0430\u0439\u0442\u0430\u0445, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0443\u043b\u0435\u0432\u044b\u0439 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0437\u043d\u0430\u043a \u0442\u0438\u043f\u0430. \u0421\u0430\u043c \u0436\u0435 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u0439 typedef:<\/p>\n<pre><code class=\"cpp\">typedef typename type_choice&lt; typename base_type_selector&lt;is_signed&gt;::base_type, sizeof(base_type_selector&lt;is_signed&gt;::base_type) == capacity &gt;::std_type type; <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0438 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u041c\u0443\u0434\u0440\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 MVS \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0431\u0435\u0437 \u0437\u0430\u043f\u0438\u043d\u043e\u043a:<\/p>\n<pre><code class=\"cpp\">template &lt;size_t capacity, bool is_signed&gt; class fixed_int {\t     \/\/ \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438      template &lt;int x&gt; struct unsupported_capacity { int i[1\/(x-x)]; };     template &lt;&gt; struct unsupported_capacity&lt;1&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;2&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;4&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;8&gt; {};      \/\/ \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430     template&lt;typename type&gt; struct type_traits;     template&lt;&gt; struct type_traits &lt;unsigned char&gt; { typedef unsigned char current_type; typedef unsigned short next_type; };     template&lt;&gt; struct type_traits &lt;unsigned short&gt; { typedef unsigned short current_type; typedef unsigned int next_type; };     template&lt;&gt; struct type_traits &lt;unsigned int&gt; { typedef unsigned int current_type; typedef unsigned long next_type; };     template&lt;&gt; struct type_traits &lt;unsigned long&gt; {\ttypedef unsigned long current_type; typedef unsigned long long next_type; };     template&lt;&gt; struct type_traits &lt;unsigned long long&gt; { typedef unsigned long long current_type;  typedef unsupported_capacity&lt;capacity&gt; next_type; };     template&lt;&gt; struct type_traits &lt;char&gt; { typedef char current_type; typedef short next_type; };     template&lt;&gt; struct type_traits &lt;short&gt; { typedef short current_type; typedef int next_type; };     template&lt;&gt; struct type_traits &lt;int&gt; { typedef int current_type; typedef long next_type; };     template&lt;&gt; struct type_traits &lt;long&gt; { typedef long current_type; typedef long long next_type; };     template&lt;&gt; struct type_traits &lt;long long&gt; { typedef long long current_type;  typedef unsupported_capacity&lt;capacity&gt; next_type;};      \/\/ \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u0438\u043f\u0430     template&lt;typename type, bool&gt;      struct type_choice      {          typedef typename type_traits&lt;type&gt;::current_type std_type;      };     template&lt;typename type&gt;      struct type_choice&lt;type, false&gt;      {          typedef typename type_traits&lt;type&gt;::next_type next_type;          typedef typename type_choice&lt;next_type, sizeof(next_type) == capacity&gt;::std_type std_type;      };      \/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u0431\u043e\u0440\u0430     template &lt;bool is_signed&gt; struct base_type_selector { typedef char base_type; };     template &lt;&gt; struct base_type_selector&lt;false&gt; { typedef unsigned char base_type; };  public:      typedef typename type_choice&lt; typename base_type_selector&lt;is_signed&gt;::base_type, sizeof(base_type_selector&lt;is_signed&gt;::base_type) == capacity &gt;::std_type type;  }; <\/code><\/pre>\n<p>  \u041c\u0435\u043d\u0435\u0435 \u0443\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Qt \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432 namespace __private, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d, \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0435\u0441\u043a\u0443 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Loki (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0442\u0438\u043f\u043e\u0432). <\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">typedef fixed_int&lt;1, false&gt;::type\tuint8; typedef fixed_int&lt;2, false&gt;::type\tuint16; typedef fixed_int&lt;4, false&gt;::type\tuint32; typedef fixed_int&lt;8, false&gt;::type\tuint64; typedef fixed_int&lt;1, true&gt;::type\tint8; typedef fixed_int&lt;2, true&gt;::type\tint16; typedef fixed_int&lt;4, true&gt;::type\tint32; typedef fixed_int&lt;8, true&gt;::type\tint64; <\/code><\/pre>\n<p>  \u2026 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e-\u0436\u0435 \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c (\u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043f\u043e\u0434 MVS2015\/intel 0x86):<\/p>\n<pre><code class=\"cpp\">... int32 x1; uint64 x2; fixed_int&lt;2, true&gt;::type x3;  std::wcout&lt;&lt;typeid(x1).name()&lt;&lt;std::endl; std::wcout&lt;&lt;typeid(x2).name()&lt;&lt;std::endl; std::wcout&lt;&lt;typeid(x3).name()&lt;&lt;std::endl; ... <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"dos\">int unsigned __int64 short <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u044b \u0438\u0434\u0443\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u044e\u0441\u043e\u043c. <\/p>\n<p>  P.S.: \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u0435\u0431\u0435\u0441\u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u0451\u043c: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\"> \/\/ \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438      template &lt;int x&gt; struct unsupported_capacity { int i[1\/(x-x)]; };     template &lt;&gt; struct unsupported_capacity&lt;1&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;2&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;4&gt; {};     template &lt;&gt; struct unsupported_capacity&lt;8&gt; {}; <\/code><\/pre>\n<p>  \u041d\u0435\u0431\u0435\u0441\u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b, \u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Microsoft \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f fixed_int&lt;3, true&gt;::type \u0432\u044b\u0434\u0430\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"cpp\">exp4.cpp(127): error C2057: expected constant expression exp4.cpp(156) : see reference to class template instantiation 'fixed_int&lt;3,true&gt;::unsupported_capacity&lt;3&gt;' being compiled ... <\/code><\/pre>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/280542\/\"> https:\/\/habrahabr.ru\/post\/280542\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u0441\u0432\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 C++, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u00ab\u0434\u0435\u0441\u044f\u0442\u043a\u0443\u00bb (char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long) \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0432\u0438\u043d\u0434\u043e\u0432\u044b\u0445 DWORD, __int64 \u0438 \u0442.\u043f. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0438\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043c\u0435\u043d\u043d\u043e 4 \u0431\u0430\u0439\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0447\u043d\u043e 4, \u0430 \u043d\u0435 \u00ab\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e\u00bb, \u00ab\u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0434\u0440\u0435\u0441\u0430\u00bb \u0438 \u0442.\u043f. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++ \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u043b\u0438\u0448\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u0440\u0430\u0441\u043f\u0435\u0432: char \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 short, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 int, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 long, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 long long. <\/p>\n<p>  \u041f\u0440\u0438\u043e\u0431\u0449\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u043c\u0430\u0433\u0438\u0438 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0440\u0435\u0448\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u2014 \u044d\u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.  <\/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-277305","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277305","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=277305"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277305\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}