{"id":182428,"date":"2013-06-07T01:14:03","date_gmt":"2013-06-06T21:14:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=182428"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=182428","title":{"rendered":"<span class=\"post_title\">\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u044b\u0435 \u043d\u0430 \u0421<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441-\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0437 5 \u043f\u043e\u043b\u0435\u0439 \u0438 10 000 000 \u0441\u0442\u0440\u043e\u043a, \u0438 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435, \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 <b>3.5 \u2013 5.3<\/b> \u0440\u0430\u0437\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <b>C++<\/b> \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b.<br \/>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0432 1.3 \u0440\u0430\u0437\u0430: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/blob\/06a80340ff403c4693bfe0ff8b80584f029c71a3\/main.cpp\">GitHub.com<\/a><br \/>  \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u044f\u0437\u044b\u043a\u0430, \u0430 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 C++ \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0430\u043f\u043e\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<br \/>  \u041c\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 MSVC11(MSVS2012) \u0438 GCC 4.7.2, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043d\u0438\u0445 C \u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++11.<br \/>  \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0451 \u043f\u0438\u0448\u0435\u043c \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435. <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>1. Hardcore-\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 C++<\/h4>\n<p>  \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u0430\u0440\u0434\u043a\u043e\u0440\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0431\u044b \u043d\u0430 C. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a \u043d\u0435\u0441\u0447\u0430\u0441\u0442\u044c\u044e \u0434\u043b\u044f C-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c 3840 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043d\u0438\u0433\u0434\u0435 \u0432 \u043d\u0438\u0445 \u043d\u0435 \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f. \u041f\u043e\u043a\u0430 C-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0445 \u043f\u0438\u0448\u0443\u0442, \u043c\u044b \u043e\u0442\u043d\u0435\u0441\u0435\u043c\u0441\u044f \u043a \u043d\u0438\u043c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0430 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u0438 3840 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430 \u0432\u0430\u0441 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 C++. \u0421\u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u043d \u044d\u0442\u043e \u043d\u0435 \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u043e \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0442\u043e\u0447\u043d\u0435\u0435, \u0447\u0435\u043c \u0438\u0445 \u043d\u0430\u043f\u0438\u0448\u0443\u0442 C-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<br \/>  \u0412\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u0421\u0423\u0411\u0414 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435, \u043a\u0430\u043a \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 (<code>selectivity<\/code>) \u2013 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439(\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430). \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0442\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u043e \u043d\u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0438 \u0442\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435 \u043c\u044b \u043f\u043e\u0439\u043c\u0435\u043c, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442. \u0422.\u0435. \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c.<br \/>  \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0421\u0423\u0411\u0414 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0438 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0443\u043c\u0430\u044e, \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0438 \u0441 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. (\u041a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 (cardinality) \u2013 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435.)<br \/>  \u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a) \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430:<br \/>  <code>selectivity = c_array_size * (1 + field.end \u2013 field.begin) \/ cardinality;<\/code><br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0410 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u043b\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439. \u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u043b\u0435\u0439, \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430.<br \/>  \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043c\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0443\u043c\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0430\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432:   <\/p>\n<ol>\n<li>\u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430 (\u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043d\u0430 C++)<\/li>\n<li>\u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430<\/li>\n<\/ol>\n<p>  \u0418\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 <code>(2^5)*5! = 32*120 = 3840<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u0440\u0430\u0437\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043d\u043e \u0441 \u043e\u0431\u0449\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u043a\u043e\u043c.<br \/>  \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0438\u0434\u0443\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043c\u0435\u0441\u0442\u0435. \u041f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0438\u043b\u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u043e\u0434.<\/p>\n<h4>2. \u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h4>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u043b\u044f\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 compile-time-\u0433\u0435\u0442\u0442\u0435\u0440\u044b. \u042d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441 \u2013 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u2013 \u0442\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u043b\u0435\u0439 \u0432 \u043a\u043e\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 <code>T_cash_account_row.<\/code><br \/>  \u0421\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<br \/>  \u0422\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u043e\u0434 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438:  <\/p>\n<pre><code class=\"cpp\">\/* Row *\/ struct T_cash_account_row {  \t\/\/ Fields: \tenum T_field_enum { amount_of_money_e, gender_e, age_e, code_e, height_e,   \/*&lt;&lt;&lt;&lt;&lt;- add fields here (with index) *\/ \t\tlast_e\t\/*&lt;&lt;&lt;&lt;&lt;- add included fields here (without index) *\/ \t}; \tstatic_assert(last_e &gt; 0, &quot;Number of indexed fields in enum of T_cash_account_row must be greater than 0!&quot;);  \tunsigned code:20;\t\t\t\/\/ 0 - 1000000 \tunsigned gender:1;\t\t\t\/\/ 0 - 1 \tunsigned age:7;\t\t\t\/\/ 0 - 100\t \tunsigned amount_of_money:20;\t\/\/ 0 - 1000000 \tunsigned height:9;\t\t\t\/\/ 0 \u2013 300   \t\/\/ Get field value template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == code_e, decltype(code)&gt;::type get_field_value() const { return code; }  template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == gender_e, decltype(gender)&gt;::type get_field_value() const { return gender; }  template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == age_e, decltype(age)&gt;::type get_field_value() const { return age; }  template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == amount_of_money_e, decltype(amount_of_money)&gt;::type get_field_value() const { return amount_of_money; }  template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == height_e, decltype(height)&gt;::type get_field_value() const { return height; }  template&lt;int field_enum&gt; inline  \ttypename std::enable_if&lt;field_enum == last_e, bool&gt;::type get_field_value() const { return true; }  \tstatic_assert(5 == last_e, &quot;Add\/delete new field-case and correct this assert!&quot;); }; \/* ----------------------------------------------------------------------- *\/ <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <code>enum T_field_enum<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 0 (<a href=\"https:\/\/code.google.com\/p\/openassist\/downloads\/detail?name=C%2B%2B%20Standard%20-%20ANSI%20ISO%20IEC%2014882%202003.pdf\">C++03 7.2 Enumeration declarations<\/a>).<br \/>  \u0428\u0430\u0431\u043b\u043e\u043d <code>std::enable_if&lt;&gt;<\/code> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>#include &lt;type_traits&gt;<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439\/\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0438 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Substitution_failure_is_not_an_error#cite_note-1\">SFINAE (substitution-failure-is-not-an-error)<\/a> \u2013 \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 (<a href=\"https:\/\/code.google.com\/p\/openassist\/downloads\/detail?name=C%2B%2B%20Standard%20-%20ANSI%20ISO%20IEC%2014882%202003.pdf\">\u0421++03 14.8.2 Template argument deduction<\/a>).<br \/>  \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0433\u0435\u0442\u0442\u0435\u0440\u0430 \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a: <br \/>  <code>auto code = row-&gt;get_field_value&lt;T_cash_account_row::code_e&gt;();<\/code><br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 5 \u043f\u043e\u043b\u0435\u0439 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 <code>std::enable_if&lt;&gt;<\/code>, \u043d\u043e \u043c\u044b \u0436\u0435 \u0434\u0443\u043c\u0430\u0435\u043c \u043d\u0430\u043f\u0435\u0440\u0451\u0434. \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0437 5 \u043f\u043e\u043b\u0435\u0439 \u0438 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0431\u044b \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u0442\u0438\u043f\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f:  <\/p>\n<pre><code class=\"cpp\">\/* Row *\/ struct T_cash_account_row {      \/\/ Fields: \tenum T_field_enum { amount_of_money_e, gender_e, age_e, code_e, height_e,   \/*&lt;&lt;&lt;&lt;&lt;- add fields here (with index) *\/ \t\tlast_e \/*&lt;&lt;&lt;&lt;&lt;- add included fields here (without index) *\/ \t}; \tstatic_assert(last_e &gt; 0, &quot;Number of indexed fields in enum of T_user_row must be greater than 0!&quot;);  \tunsigned code:20;\t\t\t\/\/ 0 - 1000000 \tunsigned gender:1;\t\t\t\/\/ 0 - 1 \tunsigned age:7;\t\t\t\/\/ 0 - 100\t \tunsigned amount_of_money:20;\t\/\/ 0 - 1000000 \tint height;\t\t\t\t\/\/ 0 \u2013 300  \t\/\/ Get field value \ttemplate&lt;int field_enum&gt; inline unsigned get_field_value(); \ttemplate&lt;int field_enum&gt; inline int get_field_value();  \tstatic_assert(5 == last_e, &quot;Add\/delete new field-case and correct this assert!&quot;); };  template&lt;&gt; inline unsigned T_cash_account_row::get_field_value&lt;T_cash_account_row::code_e&gt;() { return code; } template&lt;&gt; inline unsigned T_cash_account_row::get_field_value&lt;T_cash_account_row::gender_e&gt;() { return gender; } template&lt;&gt; inline unsigned T_cash_account_row::get_field_value&lt;T_cash_account_row::age_e&gt;() { return age; } template&lt;&gt; inline unsigned T_cash_account_row::get_field_value&lt;T_cash_account_row::amount_of_money_e&gt;() { return amount_of_money; } template&lt;&gt; inline int T_cash_account_row::get_field_value&lt;T_cash_account_row::height_e&gt;() { return height; } template&lt;&gt; inline unsigned T_cash_account_row::get_field_value&lt;T_cash_account_row::last_e&gt;() { return 1; } \/* ----------------------------------------------------------------------- *\/  int main() {     T_cash_account_row *row = new T_cash_account_row;     auto code = row-&gt;get_field_value&lt;T_cash_account_row::code_e&gt;();          return 0; } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u043e \u043d\u0435 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>get_field_value&lt;&gt;()<\/code>. <a href=\"http:\/\/ideone.com\/QgW7tH\">Ideone.com<\/a><br \/>  \u041d\u0430\u0448 \u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f: <a href=\"http:\/\/ideone.com\/9yahUB\">ideone.com<\/a><br \/>  \u0421 \u0433\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 (unrolling of template) \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0430 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 (\u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u2013 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0441 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0430 <code>operator()(\u2026)<\/code>):  <\/p>\n<pre><code class=\"cpp\">\/\/ The templated functor of unrolling of the input templated functor (reusable) template&lt;unsigned unroll_count, template&lt;unsigned&gt; class T&gt; struct T_unroll_functor { \tT_unroll_functor&lt;unroll_count-1, T&gt; next_unroll; \tT&lt;unroll_count-1&gt; functor; \ttemplate&lt;typename T1, typename T2&gt; inline bool operator()(T1 const& val1, T2 const& val2) { \t\treturn next_unroll(val1, val2) && functor(val1, val2); \t} }; \/\/ End of unroll template&lt;template&lt;unsigned&gt; class T&gt; struct T_unroll_functor&lt;0, T&gt; {  \ttemplate&lt;typename T1, typename T2&gt; inline bool operator()(T1 const&, T2 const&) { return true; }  }; \/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u043e\u0439 \u043c\u044b \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <code>last_e <\/code>\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u043f\u043e\u043b\u044f\u043c \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0448\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0433\u0435\u0442\u0442\u0435\u0440\u044b.<br \/>  \u0410 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0444\u0443\u043d\u043a\u0442\u043e\u0440<code> struct T_test_pred<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"cpp\">\/\/ The filters for each search variant (range_filters) template&lt;typename T_row, unsigned index_pred&gt; struct T_custom_filter : T_filter&lt;T_row&gt; {  \t\/\/ Test predicates functor for unrolling \ttemplate&lt;unsigned field_num&gt; \tstruct T_test_pred { \t\tbool inline operator()(T_row *const __restrict row, T_range_filters *const __restrict range_filters) const  \t\t{ \t\t\ttypedef typename T_row::T_field_enum T_field_enum; \t\t\t\/\/ Without fields where use_filter==0 \t\t\treturn ( T_filter&lt;T_row&gt;::template T_get_use_filter&lt;index_pred, field_num&gt;::value || \t\t\t\t(row-&gt;template get_field_value&lt;static_cast&lt;T_field_enum&gt;(field_num)&gt;() &gt;=  \t\t\t\trange_filters-&gt;begin.template get_field_value&lt;static_cast&lt;T_field_enum&gt;(field_num)&gt;()&&  \t\t\t\trow-&gt;template get_field_value&lt;static_cast&lt;T_field_enum&gt;(field_num)&gt;() &lt;=  \t\t\t\trange_filters-&gt;end.template get_field_value&lt;static_cast&lt;T_field_enum&gt;(field_num)&gt;())  \t\t\t); \t\t}\t\t\t \t}; \t\/\/ ----------------------------------------------------------------------- \t \t\/\/ search \tvirtual size_t search(T_row *const __restrict array_ptr, const size_t c_array_size, T_row *const __restrict result_ptr, T_range_filters *const __restrict range_filters) final \t{ \t\tsize_t result_size = 0; \t\tsize_t i; \/\/ loop index \t\tT_unroll_functor&lt;T_row::last_e, T_test_pred&gt; test_predicate; \t\tfor(i = 0; i &lt; c_array_size; ++i) { \t\t\tif(test_predicate(array_ptr + i, range_filters))  \t\t\t\tresult_ptr[result_size] = array_ptr[i], ++result_size; \t\t} \t\treturn result_size; \t} }; \/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0443 \u0435\u0449\u0451, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 <code>T_filter&lt;&gt;, T_custom_filter&lt;&gt; \u0438 T_optimized_search&lt;&gt;<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <code>T_row<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2013 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>T_cash_account_row<\/code>.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0438 \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 <code>T_cash_account_row<\/code>, \u0430 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u0442\u0438\u043f\u043e\u043c \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438: <br \/>  <code>T_optimized_search&lt;T_cash_account_row&gt; optimized_search;\t\/\/ C++ optimized search<\/code><br \/>  \u0412\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/blob\/5a99194666e8e72cca1cdfbe8652a9026191be0e\/main.cpp\">GitHub.com<\/a><br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043a\u043e\u0434\u0430 team-lead \u0438 performance-architect \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043d\u043e \u0438 \u0442\u0438\u043f\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e: <code>T_cash_account_row \u0438 T_range_filters<\/code>. \u0417\u0430\u0434\u0430\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 <code>T_cash_account_row <\/code>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0447\u0435\u0440\u0435\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0433\u0435\u0442\u0442\u0435\u0440\u044b, \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 TDD, \u0447\u0442\u043e \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<br \/>  \u041d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 MSVC11(MSVS2012) \u0438 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 CPU Core i5 K750 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<blockquote><p>Generated rows: 10000000<br \/>  C++-Searching\u2026<br \/>  C++-optimized search took 0.056000 seconds.<br \/>  Found rows: 38<br \/>  C-Searching\u2026<br \/>  C-search took 0.074000 seconds.<br \/>  The C++ faster than C: 1.321429 times<br \/>  Found rows: 38<\/p><\/blockquote>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043a\u043e\u0434 \u043d\u0430 C++ \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432 1.3 \u0440\u0430\u0437\u0430, \u0447\u0435\u043c \u043a\u043e\u0434 \u043d\u0430 C. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>test_predicate <\/code>\u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443 \u043d\u0430 C++, <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/tree\/7d0e5d577cafe6ec840475e64f8e8121dcee1379\/msvc11_disasm\">test_pradicate_enum_cpp.asm<\/a>. <br \/>  \u00ab\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 disasm \u0438\u0437 TortoiseDiff\u00bb<br \/>  <img decoding=\"async\" src=\"http:\/\/s2.ipicture.ru\/uploads\/20130607\/qVT1Iu4v.png\" alt=\"test_pradicate_enum_cpp.asm\"\/><br \/>  \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043b\u0438 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. <br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043a\u043e\u0434 \u043a \u0434\u0440\u0443\u0433\u043e\u0439, \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h4>3. \u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0432 3.5 \u2013 5.3 \u0440\u0430\u0437\u0430<\/h4>\n<p>  \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e C++, \u0433\u0434\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f compile-time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"http:\/\/habrahabr.ru\/post\/124476\/\">\u043f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445.<\/a> \u0421\u0442\u0430\u0442\u044c\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435, \u043d\u043e \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u0447\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u0430\u0432\u0442\u043e\u0440\u044b: \u00ab\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0432\u0435\u0449\u044c\u00bb.<br \/>  \u042f \u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0442 compile-time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. <\/p>\n<h5>3.1 \u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445<\/h5>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438\u0437 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c compile-time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430:  <\/p>\n<pre><code class=\"cpp\">template &lt;unsigned N&gt;  \tstruct factorial : std::integral_constant&lt;unsigned, N * factorial&lt;N-1&gt;::value&gt; {}; template &lt;&gt; struct factorial&lt;0&gt; : std::integral_constant&lt;unsigned, 1&gt; {}; <\/code><\/pre>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430<code> std::array&lt;&gt;<\/code> \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u044b\u043c <code>(2^5)*5! = 3840<\/code>.<br \/>  \u0418\u0437 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0443 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430. \u0410 \u0447\u0438\u0441\u043b\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u043e 2 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. (\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430\u043c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u043d\u043e \u044f \u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e.)<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <br \/>  <code>struct T_custom_filter<\/code> \u043f\u0440\u0438 \u0435\u0451 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.<br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043d\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0449\u0451 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>index_order<\/code>. \u0410 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0432 \u043d\u0435\u0439 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0442\u043e\u0440.  <\/p>\n<pre><code class=\"cpp\">\/\/ The filters for each search variant (range_filters) template&lt;typename T_row, unsigned index_pred, unsigned index_order = 0&gt; struct T_custom_filter : T_filter&lt;T_row&gt; {  \t\/\/ Test predicates functor for unrolling \ttemplate&lt;unsigned field_num&gt; \tstruct T_test_pred { \t\tbool inline operator()(T_row *const __restrict row, T_range_filters *const __restrict range_filters) const  \t\t{ \t\t\ttypedef typename T_row::T_field_enum T_field_enum;  \t\t\t\/\/ Without fields where use_filter==0 \t\t\tenum { ordered_field_number = T_filter&lt;T_row&gt;::template T_number_field&lt;index_order, field_num&gt;::value };  \t\t\treturn ( T_filter&lt;T_row&gt;::template T_get_use_filter&lt;index_pred, ordered_field_number&gt;::value || \t\t\t\t(row-&gt;template get_field_value&lt;static_cast&lt;T_field_enum&gt;(ordered_field_number)&gt;() &gt;=  \t\t\t\trange_filters-&gt;begin.template get_field_value&lt;static_cast&lt;T_field_enum&gt;(ordered_field_number)&gt;() &&  \t\t\t\trow-&gt;template get_field_value&lt;static_cast&lt;T_field_enum&gt;(ordered_field_number)&gt;() &lt;=  \t\t\t\trange_filters-&gt;end.template \tget_field_value&lt;static_cast&lt;T_field_enum&gt;(ordered_field_number)&gt;())  \t\t\t); \t\t}\t\t\t \t}; \t\/\/ ----------------------------------------------------------------------- \t\/\/ search \tvirtual size_t search(T_row *const __restrict array_ptr, const size_t c_array_size, T_row *const __restrict result_ptr, T_range_filters *const __restrict range_filters) final; }; \/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u0448\u0430\u0431\u043b\u043e\u043d <code>T_get_use_filter <\/code>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u043b\u0430\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (\u0438\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f) \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043f\u043e \u043f\u043e\u043b\u044e <code>number_filter <\/code>\u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 index_pred.  <\/p>\n<pre><code class=\"cpp\">\/\/ whether to use the filter for a given predicate? (strictly at compile time) template &lt;unsigned index_pred, unsigned number_filter&gt;  struct T_get_use_filter : std::integral_constant&lt;bool, !(index_pred & 1&lt;&lt;number_filter)&gt; {}; <\/code><\/pre>\n<p>  \u0418\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430<code> T_number_field&lt;&gt;<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 <code>index_order  <\/code>\u2013 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u044f <code>field_num<\/code>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f <code>ordered_field_number <\/code>\u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0433\u0435\u0442\u0442\u0435\u0440\u0430 <code>get_field_value&lt;static_cast&lt;T_field_enum&gt;(ordered_field_number)&gt;()<\/code>.<\/p>\n<h5>3.2 \u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445<\/h5>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043f\u043e\u043b\u044f \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>T_number_field&lt;&gt;<\/code>. \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043f\u043e\u043b\u0435\u0439 <code>index_order <\/code>\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u2013 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f 5 \u043f\u043e\u043b\u0435\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<br \/>  <code>index_order = field0 + 5*field1 + 5*4*field2 + 5*4*3*field3 + 5*4*3*2*field4;<\/code><br \/>  \u0433\u0434\u0435 <code>field1 <\/code>\u2013 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f \u043e\u0442 0 \u0434\u043e 4-\u0438\u0445 (\u0438\u0437 5-\u0442\u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f), \u0438\u0434\u0443\u0449\u0438\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438; field2 \u2013 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f \u043e\u0442 0 \u0434\u043e 3 (\u0438\u0437 4-\u0435\u0445 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f), \u0438\u0434\u0443\u0449\u0438\u0439 \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438; \u2026; \u0430 field5 \u2013 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f \u043e\u0442 0 \u0434\u043e 0 (\u0438\u0437 1-\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0433\u043e\u0441\u044f) \u0438\u0434\u0443\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c, \u0442.\u043a. \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 0, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<br \/>  <code>index_order = field0 + 5*field1 + 5*4*field2 + 5*4*3*field3;<\/code><br \/>  \u0438\u043b\u0438, \u0447\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435:<br \/>  <code>index_order = field0 + 5*(field1 + 4*(field2 + 3*(field3)));<\/code><br \/>  \u041a\u043e\u043c\u0443-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 index_order, \u043a\u0430\u043a \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438\u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 <code>field0 <\/code>\u2013 \u043f\u0435\u0440\u0432\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u0441 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 5 (\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c 5 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 0-4), \u0432 <code>field1 <\/code>\u2013 \u0432\u0442\u043e\u0440\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u0441 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 4 (\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c 4 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 0-3), \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 (5!) \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0435\u0439. \u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c \u0438\u0437 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438.<br \/>  \u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0430\u043a: \u043a\u0440\u0443\u0433\u043b\u044b\u043c\u0438 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438 () \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0435), \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u043c [] \u2013 \u0435\u0433\u043e \u043d\u043e\u043c\u0435\u0440 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f, \u0430 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u043c\u0438 {} \u2013 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0435\u043c 5 \u043f\u043e\u043b\u0435\u0439 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c\u0438: 5, 3, 1, 2, 4  <\/p>\n<pre> \u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f:\t    0 1  2  3 4 \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:5 3 (1) 2 4\t- [2] \u2013 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f (field0) {2} \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:5 3 (2) 4\t- [2] \u2013 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f (field1) {3} \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:5 (3) 4\t- [1] \u2013 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f (field2) {1} \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:5 (4)\t- [1] \u2013 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f (field3) {4} \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:(5)\t\t- [0] \u2013 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f (field4) {0} <\/pre>\n<p>  \u041f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0432 \u0447\u0438\u0441\u043b\u0430 \u0432:<code> index_order = field0 + 5*(field1 + 4*(field2 + 3*(field3)));<\/code><br \/>  \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<code> index_order = 2 + 5*(2 + 4*(1 + 3*(1))) = 92;<\/code><br \/>  \u041f\u043e\u0437\u0436\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 run-time \u0444\u0443\u043d\u043a\u0446\u0438\u0438<code> T_optimized_search::get_index_order().<\/code><br \/>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0436\u0435, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0438 \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u0430\u043a \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0432 compile-time.<br \/>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 []. \u0412 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u00ab\u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0435\u0439\u00bb \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438<code> index_order = 2 + 5*(2 + 4*(1 + 3*(1))) = 92<\/code>:  <\/p>\n<pre> field0 = index_order % 5 = 92 % 5 = 2; field1 = (index_order\/5) % 4 = (92\/5) % 4 = 2; field2 = (index_order\/(5*4)) % 3 = (92\/5*4) % 3 = 1; field3 = (index_order\/(5*4*3)) % 2 = (92\/5*4*3) % 2 = 1; field4 = 0; <\/pre>\n<p>  \u0412 compile-time \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:  <\/p>\n<pre><code class=\"cpp\">\/\/ Get the sequence number the remaining field for the number_filter, after removal of all previous  template &lt;unsigned index_order, unsigned number_filter, unsigned index = T_row::last_e&gt;  struct T_number_remaining_field : std::integral_constant&lt;unsigned, T_number_remaining_field&lt;index_order \/ index, number_filter - 1, index - 1&gt;::value&gt; {};  \/\/ End of unroll template &lt;unsigned index_order, unsigned index&gt;  struct T_number_remaining_field&lt;index_order, 0, index&gt; : std::integral_constant&lt;unsigned, index_order % index&gt; {}; \/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00ab\u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u044f\u00bb \u0440\u0430\u0432\u043d\u043e\u0433\u043e number_filter, \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c <code>T_number_remaining_field&lt;index_order, number_filter&gt;::value<\/code>.<br \/>   \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442, \u0433\u0434\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f: \u043a\u0442\u043e-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 (<code>number_filter=0<\/code>), \u0442.\u0435. <code>T_number_remaining_field&lt;index_order, 0&gt;::value<\/code> \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<br \/>  <code>template &lt;unsigned index_order, unsigned index&gt; struct T_number_remaining_field&lt;index_order, 0, index&gt;  <\/code><br \/>  \u0413\u0434\u0435 <code>index_order <\/code>\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 <code>index_order<\/code>, \u0430 0 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 <code>index<\/code>. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a!<br \/>  \u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 (<a href=\"https:\/\/code.google.com\/p\/openassist\/downloads\/detail?name=C%2B%2B%20Standard%20-%20ANSI%20ISO%20IEC%2014882%202003.pdf\">\u0421++03 14.8.2 Template argument deduction<\/a>), \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437 \u043e\u0431\u0449\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<code> index = T_row::last_e<\/code> \u0438 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0448\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 <code>T_number_remaining_field&lt;index_order, 0, T_row::last_e&gt;::value<\/code>. \u0410 \u0437\u0430\u0442\u0435\u043c \u0443\u0436\u0435 \u0438\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438: <br \/>  <code>template &lt;unsigned index_order, unsigned index&gt; struct T_number_remaining_field&lt;index_order, 0, index&gt;  <\/code><br \/>  \u0418 \u0434\u043b\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u044f \u0438\u0437 5 \u043f\u043e\u043b\u0435\u0439 (<code>T_row::last_e=5<\/code>) \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>index_order % 5<\/code>, \u0447\u0442\u043e \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c.<br \/>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u00ab\u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u043b\u0435\u0439\u00bb \u0442\u0435\u0445, \u0447\u0442\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0442\u0435\u0445, \u0447\u0442\u043e \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 {}.<br \/>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u00ab\u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0435\u0439\u00bb \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 [] \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u043f\u043e\u043b\u0435\u0439 \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 {}. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u043e\u0434\u0443 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u0440\u0442 \u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u0441\u043d\u0438\u0437\u0443-\u0432\u0432\u0435\u0440\u0445, \u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0445 \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043a\u043e\u043b\u043e\u0434\u0435. \u041d\u043e \u0432\u044b\u043d\u0438\u043c\u0430\u044f \u043a\u0430\u0440\u0442\u044b \u0438\u0437 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b, \u0443 \u0442\u0435\u0445 \u043a\u0430\u0440\u0442, \u0447\u0442\u043e \u043b\u0435\u0436\u0430\u0442 \u0432\u044b\u0448\u0435 \u043d\u0438\u0445, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0432 \u043a\u043e\u043b\u043e\u0434\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0445 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430.<br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 {} \u0438 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 () (\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0437\u044b\u043c\u0430\u044e\u0442\u0441\u044f), \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0442 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u00ab\u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f\u00bb [], \u0447\u0435\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0431\u043e\u043b\u044c\u0448\u0435. \u0422\u0430\u043a\u0438\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b:  <\/p>\n<pre><code class=\"cpp\">\t\/\/ Get 1 or 0 offset if current_field (for number_filter) affect to number_field \ttemplate &lt;unsigned index_order, unsigned number_filter, unsigned number_field&gt; \tstruct T_offset { \t\tenum { current_field = T_number_remaining_field&lt;index_order, number_filter&gt;::value, \t\tvalue = (current_field &lt;= number_field)?1:0 }; \t}; \t \t\/\/ Get offset of number_field (enum in row-type) for number_filter \ttemplate &lt;unsigned index_order, unsigned number_filter, unsigned number_field&gt; \tstruct T_offset_number_field { \t\tenum { offset = T_offset&lt;index_order, number_filter-1, number_field&gt;::value, \t\tvalue = T_offset_number_field&lt;index_order, number_filter-1, number_field + offset&gt;::value + offset }; \t};  \t\/\/ End of unroll template &lt;unsigned index_order, unsigned number_field&gt; struct T_offset_number_field&lt;index_order, 0, number_field&gt; : \tstd::integral_constant&lt;unsigned, 0&gt; {}; <\/code><\/pre>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0435\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c:  <\/p>\n<pre><code class=\"cpp\">\t\/\/ (Main) Get number of field (enum in row-type) for number_filter \ttemplate &lt;unsigned index_order, unsigned number_filter&gt; \tstruct T_number_field { \t\tenum { remaining_field = T_number_remaining_field&lt;index_order, number_filter&gt;::value, \t\tvalue = remaining_field + T_offset_number_field&lt;index_order, number_filter, remaining_field&gt;::value }; \t}; \t\/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e.<\/p>\n<h5>3.3 \u0412\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432<\/h5>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u0444\u0438\u043b\u044c\u0442\u0440\u0430 <code>T_custom_filter&lt;&gt;<\/code> \u043f\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u043f\u043e \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432:  <\/p>\n<pre><code class=\"cpp\">template&lt;typename T_row&gt; class T_optimized_search { \t\/\/ unroll tamplates \ttemplate&lt;unsigned index_pred&gt; \tstruct T_unroll_find { \t\ttemplate&lt;unsigned index_order&gt; \t\tstruct T_unroll_order { \t\t\ttemplate&lt;typename T&gt; T_unroll_order(T &filters) {  \t\t\t\tfilters[index_pred + index_order*(1&lt;&lt;T_row::last_e)].reset( new T_custom_filter&lt;T_row, index_pred, index_order&gt;() );  \t\t\t} \t\t}; \t\tT_unroll_constructor&lt;factorial&lt;T_row::last_e&gt;::value, T_unroll_order&gt; fill_ordered_filter;  \t\ttemplate&lt;typename T&gt; T_unroll_find(T &filters) : fill_ordered_filter(filters) \t\t{} \t}; \t\/\/ -------------------------------------------------------------------------  \tstd::array&lt;std::unique_ptr&lt;T_filter&lt;T_row&gt;&gt;, (1&lt;&lt;T_row::last_e)*factorial&lt;T_row::last_e&gt;::value&gt; filters; \tT_unroll_constructor&lt; 1&lt;&lt;T_row::last_e, T_unroll_find&gt; fill_filter; public: \tT_optimized_search() : fill_filter(filters) {}  \t\/\/ C++ optimized search \tinline size_t search(T_row *const __restrict array_ptr, const size_t c_array_size, \t\tT_row *const __restrict result_ptr, T_range_filters *const __restrict range_filters)  \t{ \t\tauto const& filter = filters[T_filter&lt;T_row&gt;::get_index_pred(range_filters) +  \t\t\tT_filter&lt;T_row&gt;::get_index_order(range_filters)*(1&lt;&lt;T_row::last_e)]; \t\treturn filter-&gt;search(array_ptr, c_array_size, result_ptr, range_filters); \t} }; \/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 compile-time \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 <code>struct T_unroll_find&lt;&gt;<\/code>, \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 <code>struct T_unroll_order&lt;&gt;<\/code>.<br \/>  \u0410 \u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c run-time \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>get_index_pred()<\/code> \u2013 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>get_index_order()<\/code> \u2013 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439.<br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0442\u043e\u0439 \u0436\u0435:   <\/p>\n<pre><code class=\"cpp\">\t\/\/ Get index of T_test_pred version for current search range  \tstatic inline const unsigned get_index_pred(T_range_filters *const __restrict range_filters) \t{ \t\tunsigned result = 0; \t\tfor(size_t i = 0; i &lt; T_row::last_e; ++i)  \t\t\tresult |= range_filters-&gt;use_filter[i]?(1&lt;&lt;i):0; \t\treturn result; \t} \t\/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u0442\u043e\u0440\u0430\u044f <code>get_index_order()<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0442\u043e\u0447\u043d\u044e, \u0447\u0442\u043e \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 <code>struct T_cash_account_row<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f<code> get_bitf_size() <\/code>\u2013 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0435, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 switch\/case, \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a\u0430\u043a constexpr, \u0442.\u0435. \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u043e\u0439 compile-time, \u043d\u043e MSVC11 \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442):  <\/p>\n<pre><code class=\"cpp\">\/* Row *\/ struct T_cash_account_row { \t... \t\/\/ Get cardinality \ttemplate&lt;int field_enum&gt; \t\/\/ constexpr \/\/ not supported in the MSVS2012(MVCC11) \tstatic inline const unsigned int get_bitf_size() {  \t\treturn (field_enum == gender_e)? \t\t1: \t\t\t(field_enum == age_e)?\t\t100: \t\t\t(field_enum == height_e)?\t\t300: \t\t\t(field_enum == code_e)?\t\t1000000: \t\t\t(field_enum == amount_of_money_e)?1000000: \t\t\t0; \t\tstatic_assert(5 == last_e, &quot;Add\/delete new field-case and correct this assert!&quot;); \t} }; <\/code><\/pre>\n<p>  \u0418 \u0435\u0449\u0451 \u0440\u0430\u0437 \u043d\u0430\u043f\u043e\u043c\u043d\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a):<br \/>  <code>selectivity = c_array_size * (1 + field.end \u2013 field.begin) \/ cardinality;<\/code><br \/>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f\/\u043f\u043e\u043b\u044f:  <\/p>\n<pre><code class=\"cpp\">\t\/\/ The unrolling filling of selectivity in a compile-time \ttemplate&lt;unsigned field_num&gt; \tstruct T_selectivity_fill { \t\tT_selectivity_fill(std::map&lt;unsigned, unsigned&gt; *const __restrict ordered_filters, T_range_filters *const __restrict range_filters)  \t\t{  \t\t\t\/\/ selectivity for each field-filter \t\t\tconst unsigned selectivity = range_filters-&gt;use_filter[field_num]? \t\t\t\t((1 +  \t\t\t\t\trange_filters-&gt;end.template get_field_value&lt;field_num&gt;() -  \t\t\t\t\trange_filters-&gt;begin.template get_field_value&lt;field_num&gt;()\t)*c_array_size \/  \t\t\t\tT_row::template get_bitf_size&lt;field_num&gt;()) \/\/ cardinality \t\t\t\t:c_array_size; \t\t\tordered_filters-&gt;insert(std::make_pair(field_num, selectivity));\t \t\t} \t}; \t\t \t\/\/ Get index of T_test_pred version for current search range  \tstatic inline const unsigned get_index_order( \t\tT_range_filters *const __restrict range_filters)  \t{ \t\tunsigned result = 0;  \t\tstd::map&lt;unsigned, unsigned&gt; ordered_filters;\t \t\tT_unroll_constructor&lt;T_row::last_e, T_selectivity_fill&gt; selectivity_fill(&ordered_filters, range_filters);  \t\tunsigned multiplexor = 1; \t\tfor(size_t i = 0; i &lt; T_row::last_e; ++i) { \t\t\tunsigned cur_index = 0, min_index = 0; \t\t\tunsigned field_num = ordered_filters.cbegin()-&gt;first; \t\t\tunsigned min = c_array_size; \t\t\tfor(auto const& it : ordered_filters) { \t\t\t\tif (it.second &lt; min)  \t\t\t\t\tmin = it.second, field_num = it.first, min_index = cur_index; \t\t\t\t++cur_index; \t\t\t} \t\t\tordered_filters.erase(field_num); \t\t\tresult += min_index*multiplexor; \t\t\tmultiplexor *= (T_row::last_e - i); \t\t} \t\treturn result; \t} \t\/\/ ------------------------------------------------------------------------- <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043a\u043b\u044e\u0447 \u0432<code> std::map&lt;&gt;<\/code> \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u043f\u043e\u043b\u0435\u0439, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e. \u0417\u0430\u0442\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f, \u043f\u043e \u043d\u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 <code>std::map&lt;&gt;<\/code>, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0418 \u0442\u0430\u043a \u0432 \u0446\u0438\u043a\u043b\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u041c\u044b \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>get_index_order<\/code>, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438:<br \/>  <code>index_order = field1 + 5*(field2 + 4*(field3 + 3*(field4)));<\/code><br \/>  \u0422\u0430\u043a \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d <code>3840 <\/code>\u0440\u0430\u0437, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 run-time \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043f\u043e\u0438\u0441\u043a\u0430, \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430.<br \/>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>test_predicate <\/code>\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043d\u0430 C++ \u2013 \u0434\u0432\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u043f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/tree\/7d0e5d577cafe6ec840475e64f8e8121dcee1379\/msvc11_disasm\">github.com asm<\/a>. <br \/>  \u00ab\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0438\u0437 TortoiseDiff\u00bb<br \/>   <img decoding=\"async\" src=\"http:\/\/s1.ipicture.ru\/uploads\/20130607\/2N6j1ic6.png\" alt=\"image\"\/><\/p>\n<h4>4. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432<\/h4>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 C++: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/blob\/ba568e1f9652ae106d4e50f978ff074269d16bc9\/main.cpp\">GitHub.com<\/a><br \/>  \u041d\u0430 GCC4.7.2 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \u2013O3 \u2013march=native, CPU Core i5 K750 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c exe-\u0444\u0430\u0439\u043b\u0430 \u0432 1.3\u041c\u0411 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<blockquote><p>Generated rows: 10000000<br \/>  C++-Searching\u2026<br \/>  C++-optimized search took 0.017000 seconds.<br \/>  Found rows: 38<br \/>  C-Searching\u2026<br \/>  C-search took 0.090000 seconds.<br \/>  The C++ faster than C: 5.294118 times<br \/>  Found rows: 38<\/p><\/blockquote>\n<p>  \u0410 \u043d\u0430 MSVC11(MSVS2012) \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \/O2 \/Ob2 \/Oi, CPU Core i5 K750 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c exe-\u0444\u0430\u0439\u043b\u0430 \u0432 1.42\u041c\u0411 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<blockquote><p>Generated rows: 10000000<br \/>  C++-Searching\u2026<br \/>  C++-optimized search took 0.021000 seconds.<br \/>  Found rows: 38<br \/>  C-Searching\u2026<br \/>  C-search took 0.074000 seconds.<br \/>  The C++ faster than C: 3.523809 times<br \/>  Found rows: 38<\/p><\/blockquote>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u043f\u0430\u043b\u043e \u0441 74\u043c\u0441 \u043d\u0430 C, \u0434\u043e 21\u043c\u0441 \u043d\u0430 C++, \u0442.\u0435. \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u0440\u043e\u0441\u043b\u0430 \u0432 <b>3.5 \u0440\u0430\u0437\u0430<\/b>. \u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0418 \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e GCC \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0432 <b>5.3 \u0440\u0430\u0437\u0430<\/b>. \u0418 \u044d\u0442\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043a\u0440\u043e\u0441\u0441-\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0438 cache-prefetch. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/138132\/\">PDO<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 3840 \u043f\u0443\u0442\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u0437\u0430\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0442\u044c C++. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u0445\u043e\u0440\u043e\u0448\u043e C++ \u0442\u043e \u0443 \u0432\u0430\u0441 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u2013 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 C.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0432\u0435\u044f\u0442\u044c \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043d\u0430 C \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440. \u0422.\u043a. \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 C \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0442\u043e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439.<br \/>  \u0412\u043e\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 C: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/blob\/ba568e1f9652ae106d4e50f978ff074269d16bc9\/main.cpp\">GitHub.com<\/a><br \/>  \u0427\u0435\u043c \u043e\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 C-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 diff \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/commit\/ba568e1f9652ae106d4e50f978ff074269d16bc9#diff-0\">GitHub.com<\/a><br \/>  \u041d\u0430 GCC4.7.2 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \u2013O3 \u2013march=native, CPU Core i5 K750 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<blockquote><p>Generated rows: 10000000<br \/>  C-optimized-Searching\u2026<br \/>  C-optimized-search took 0.049000 seconds.<br \/>  Found rows: 38<br \/>  C-Searching\u2026<br \/>  C-search took 0.086000 seconds.<br \/>  The C++ faster than C: 1.755102 times<br \/>  Found rows: 38<\/p><\/blockquote>\n<p>  \u0410 \u043d\u0430 MSVC11 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \/O2 \/Ob2 \/Oi, CPU Core i5 K750 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<blockquote><p>Generated rows: 10000000<br \/>  C-optimized-Searching\u2026<br \/>  C-optimized-search took 0.045000 seconds.<br \/>  Found rows: 38<br \/>  C-Searching\u2026<br \/>  C-search took 0.074000 seconds.<br \/>  The C++ faster than C: 1.644444 times<br \/>  Found rows: 38<\/p><\/blockquote>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 C \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u043e\u0442 \u043d\u0430\u0448\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 C++ \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 <b>2 \u2014 3 \u0440\u0430\u0437\u0430<\/b>. <br \/>  \u041d\u0430 GCC \u043d\u0430 C \u0432 <b>1.8<\/b> \u0440\u0430\u0437\u0430 \u043f\u0440\u043e\u0442\u0438\u0432 <b>5.3<\/b> \u0440\u0430\u0437\u0430 \u043d\u0430 C++, \u0438 \u043d\u0430 MSVC \u043d\u0430 C \u0432 <b>1.6<\/b> \u0440\u0430\u0437\u0430 \u043f\u0440\u043e\u0442\u0438\u0432 <b>3.5<\/b> \u0440\u0430\u0437\u0430 \u043d\u0430 C++. \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 C \u043b\u0435\u0433\u043a\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c C++ \u0431\u0435\u0437 \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<h4>5. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u042f \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e C++\u2013\u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u043a\u0440\u043e\u0441\u0441-\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432 <b>3.5 \u2013 5.3<\/b> \u0440\u0430\u0437\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. <br \/>  \u041d\u0435\u0442 \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0432 C, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432 C++, \u0442.\u043a. \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c. \u0410 \u0432\u043e\u0442 \u0432 C \u2013 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 C++\u2013\u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u2013 \u044d\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043a\u0438, \u0441\u043e\u0442\u043d\u0438 \u0438 \u0442\u044b\u0441\u044f\u0447\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2013 \u0432\u043e\u0442 \u0443\u0436 \u0433\u0434\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e copy-paste.<br \/>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u044d\u0442\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u0432 Java \u0438 C#, \u0442.\u043a. \u0432 generics \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u044b. Java \u0438 C# \u0438\u043c\u0435\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u2013 \u044d\u0442\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0433\u043b\u0443\u043f\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<br \/>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u044f \u043e\u043f\u0438\u0448\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u043f\u043e\u0447\u0435\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u043c\u0443\u043b\u044c\u0442\u0438-\u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f Index Hash Join \u0438 Bitmap AND, \u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c Index Organized Tables \u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c Index Only Scan. \u041e\u043f\u0438\u0448\u0443 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441. \u0414\u043e\u0431\u044c\u0435\u043c\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0442 0.15 \u0434\u043e 3.6 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 Core i5 K750, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441\u043e \u0441\u043b\u0430\u0431\u044b\u043c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0438 \u0440\u0435\u0434\u043a\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438. \u0423\u0441\u043a\u043e\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043f\u043e\u0438\u0441\u043a \u043d\u0430 GPU \u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0437\u0430 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u2013 distributed states, \u0441 \u043e\u0434\u043d\u0438\u043c \u0431\u0430\u0440\u044c\u0435\u0440\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0433\u0440\u0443\u043f\u043f\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0417\u0430\u0442\u0435\u043c \u0432\u043f\u043b\u043e\u0442\u043d\u0443\u044e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u043c \u043a \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e web-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c FastCGI \u0438 boost::asio. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435 \u0441\u0440\u0430\u0437\u0443.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/182428\/\"> http:\/\/habrahabr.ru\/post\/182428\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441-\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0437 5 \u043f\u043e\u043b\u0435\u0439 \u0438 10 000 000 \u0441\u0442\u0440\u043e\u043a, \u0438 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435, \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 <b>3.5 \u2013 5.3<\/b> \u0440\u0430\u0437\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <b>C++<\/b> \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b.<br \/>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0432 1.3 \u0440\u0430\u0437\u0430: <a href=\"https:\/\/github.com\/AlexeyAB\/cpp_find_order\/blob\/06a80340ff403c4693bfe0ff8b80584f029c71a3\/main.cpp\">GitHub.com<\/a><br \/>  \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u044f\u0437\u044b\u043a\u0430, \u0430 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 C++ \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0430\u043f\u043e\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<br \/>  \u041c\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 MSVC11(MSVS2012) \u0438 GCC 4.7.2, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043d\u0438\u0445 C \u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++11.<br \/>  \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0451 \u043f\u0438\u0448\u0435\u043c \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435.   <\/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-182428","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182428","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=182428"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182428\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}