{"id":182824,"date":"2013-06-10T19:14:04","date_gmt":"2013-06-10T15:14:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=182824"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=182824","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0431\u0435\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u043e\u0431\u0445\u043e\u0434\u0435. <a name=\"habracut\"><\/a><\/p>\n<h4>\u041d\u0430 \u043f\u0440\u0430\u0432\u0430\u0445 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0432 C++, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:  <\/p>\n<ol>\n<li>\u041f\u0440\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a\u0430\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <i>\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/i> (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Virtual_method_table\">vtable<\/a>) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. Vtable \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (offset) \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041a\u043e\u0433\u0434\u0430, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430, \u0435\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 Vtable \u043a\u043b\u0430\u0441\u0441\u0430. \u0422.\u043a. \u044d\u0442\u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 Vtable \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0441\u043e\u0437\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043e\u0442\u043a\u0430\u0436\u0443\u0442. \u042d\u0442\u043e \u2014 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0432\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.<\/li>\n<li>\u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0421++, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0441\u0432\u044f\u0436\u0443\u0442 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c, \u0447\u0435\u0433\u043e \u041e\u0421 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 (\u041e\u0421 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u044d\u0442\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u0443\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f). \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u0432\u043c\u0435\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 C++, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f.<\/li>\n<li>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b-\u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0442.\u0435., \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 \u044d\u0442\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043e\u0434\u043d\u0430 \u043a\u043e\u043f\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432-\u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c).<\/li>\n<li>\u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f <i>\u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/i> (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Mutual_exclusion\">mutual exclusion<\/a>) \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <i>IPC<\/i> (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Inter-process_communication\">inter-process communication<\/a>)<\/li>\n<\/ol>\n<p>  \u00abCuriously Recurring Template Pattern\u00bb (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Curiously_recurring_template_pattern\">CRTP<\/a>) \u2014 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044e. CRTP \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f CRTP, \u043a\u043b\u0430\u0441\u0441 Derived \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Base, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043b\u0430\u0441\u0441\u0430 Derived. \u0414\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, Base \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 Deletor, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.  <\/p>\n<pre><code class=\"cpp\">class Deletor  { public:     virtual ~Deletor() {} };   template&lt;typename T&gt;  class Base: public Deletor  { public:      int  Run() { return static_cast&lt;T*&gt;(this)-&gt;DoIt(); } };   class Derived1: public Base&lt;Derived1&gt;  { public:     int  DoIt() { \/* implementation for Derived1 *\/  } };   class Derived2 : public Base&lt;Derived2&gt;  { public:     int  DoIt() { \/* implementation for Derived2 *\/  } };   int main()  {     Derived1 Obj1;     Derived2 Obj2;       Obj1.Run(); \/* runs DoIt() implementation *\/     Obj2.Run(); \/* runs DoIt() implementation *\/ }; <\/code><\/pre>\n<p>  \u0411\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0438\u043f\u0430 Deletor, \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 CRTP \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f. Base \u0438 Base \u2014 \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u043e\u044d\u0442\u043e\u043c, \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 BaseDeletor* \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c (\u0432\u044b\u0437\u044b\u0432\u0430\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 DoIt(), \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435). CRTP \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<h4>\u041c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f)<\/h4>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0434\u0435\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432, \u0430 \u043d\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. \u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0426\u0435\u043b\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0437\u0430\u0442\u0435\u043c, \u043f\u0440\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u0442\u0438\u043f\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>int siRun(int&)<\/code>. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>RunnableInterface<\/code> \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>Run_T<\/code> \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>  <code>Run_T(...)<\/code> \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0438 \u0442\u0435 \u0436\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0447\u0442\u043e \u0438 <code>siRun(..)<\/code>, \u043f\u043b\u044e\u0441 \u043e\u0434\u0438\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>*m_pfnRun_T<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0443\u043b\u0435\u043c, \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e (<code>Init<\/code>), \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<code>&Run_T&lt;T&gt;<\/code>) \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e (<code>siRun<\/code>) \u0434\u043b\u044f \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.  <\/p>\n<pre><code class=\"cpp\">class RunnableInterface  { private:     int  (*m_pfnRun_T)(void* const, int&);      template&lt;typename T&gt;     static int Run_T(void* const pObj, int &k) { return static_cast&lt;T*&gt;(pObj)-&gt;siRun( k ); } protected:     template&lt;typename T&gt;     void Init() { m_pfnRun_T = &Run_T&lt;T&gt;; } public:     RunnableInterface(): m_pfnRun_T(0) {}     int siRun(int &k)      {         assert(m_pfnRun_T); \/\/ Make sure Init() was called.         return (*m_pfnRun_T)(this, k);      }     virtual ~RunnableInterface() {} }; <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e <code>*m_pfnRun_T<\/code> \u043d\u0438 \u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c <code>\u0422<\/code>. <code>void* const pObj<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 <code>RunnableInterface<\/code>, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0445 \u043e\u0442 \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0442\u0430\u043a \u0441\u043a\u0430\u0436\u0435\u043c, \u043d\u0435\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e \u00ab\u043f\u043e\u0434\u0430\u0432\u0438\u0442\u00bb \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>siRun()<\/code>), \u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <code>static_cast<\/code> \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0435\u0442\u0435, \u0443\u043f\u0430\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0435\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <i>SFINAE<\/i> (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Substitution_failure_is_not_an_error\">substitution failure is not an error<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f; \u043c\u0430\u043a\u0440\u043e\u0441 <code>CreateMemberFunctionChecked<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u00ab\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00bb \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 <code>CheckMemberFunction<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>Init()<\/code>, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>FNNAME<\/code> \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438; \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 <code>CheckMemberFunction<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0438\u043f <code>\u0422<\/code>.  <\/p>\n<pre><code class=\"cpp\">\/\/ Using the SFINAE (Substitution Failure Is Not An Error) technique, \/\/ the following macro creates a template class with typename T and a \/\/ static boolean member &quot;value&quot; that is set to true if the specified \/\/ member function exists in the T class. \/\/ This macro was created based on information that was retrieved from \/\/ the following URLs: \/\/ https:\/\/groups.google.com\/forum\/?fromgroups#!topic\/comp.lang.c++\/DAq3H8Ph_1k \/\/ http:\/\/objectmix.com\/c\/779528-call-member-function-only-if-exists-vc-9-a.html   #define CreateMemberFunctionChecker(FNNAME)                             template&lt;typename T&gt; struct has_member_##FNNAME;                                                                                                  template&lt;typename R, typename C&gt; class has_member_##FNNAME&lt;R C::*&gt;  {    private:                                                                 template&lt;R C::*&gt;     struct helper;                                            template&lt;typename T&gt;     static char check(helper&lt;&T::FNNAME&gt;*);               template&lt;typename T&gt;     static char (& check(...))[2];               public:                                                                  static const bool value = (sizeof(check&lt;C&gt;(0)) == sizeof(char));  }   \/\/ This corresponding macro is used to check the existence of the \/\/ interface function in the derived class. #define CheckMemberFunction(FNNAME, FNPROTOTYPE)          { assert(has_member_##FNNAME&lt;FNPROTOTYPE&gt;::value); } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c <code>RunnableInterface<\/code>:  <\/p>\n<pre><code class=\"cpp\">class RunnableInterface  { private:     CreateMemberFunctionChecker(siRun);     int  (*m_pfnRun_T)(void* const, int&);     template&lt;typename T&gt;     static int Run_T(void* const pObj, int &k ) { return static_cast&lt;T*&gt;(pObj)-&gt;siRun(k); } protected:     template&lt;typename T&gt;      void  Init()      {         CheckMemberFunction(siRun, int (T::*)(int&));         m_pfnRun_T = &Run_T&lt;T&gt;;      } public:     RunnableInterface(): m_pfnRun_T(0) {}     virtual ~RunnableInterface() {}     int siRun(int &k)      {         assert(m_pfnRun_T);         return (*m_pfnRun_T)(this, k);      } };  <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>int siRun(int &k)<\/code>. \u0412\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>Init&lt;Derived&gt;();<\/code> \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f <code>int Derived::siRun(int &k)<\/code> \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e (<code>Run_T<\/code>), \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:   <\/p>\n<pre><code class=\"cpp\">class Test: public RunnableInterface  {     friend class RunnableInterface; private:     int siRun(int &k) { k = m_value*2; return 0; } protected:     int m_value; public:     Test(int value): m_value(value) { RunnableInterface::Init&lt;Test&gt;(); } };  class AdjustmentTest: public Test {     friend class RunnableInterface; private:     int siRun(int &k) { k = m_value*3; return 0; } public:     AdjustmentTest(int value): Test(value) { RunnableInterface::Init&lt;AdjustmentTest&gt;(); } }; <\/code><\/pre>\n<p>  <code>friend class RunnableInterface;<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>RunnableInterface<\/code> \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>private<\/code> \u0438\u043b\u0438 <code>protected<\/code>.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0431\u0445\u043e\u0434 \u043f\u043e \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 <code>TestInterface*<\/code> \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c (\u0447\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e \u0441 CRTP), \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435:  <\/p>\n<pre><code class=\"cpp\">int main() {       RunnableInterface* const pObj1 = new Test(1);     RunnableInterface* const pObj2 = new AdjustmentTest(4);       std::list&lt;RunnableInterface*&gt; list1;     list1.insert(list1.end(), pObj1);     list1.insert(list1.end(), pObj2);      std::list&lt;RunnableInterface*&gt;::iterator i;     for (i = list1.begin(); i != list1.end(); i++ )      {         RunnableInterface* const p = *i;         int k;         const int j = p-&gt;siRun(k);         std::cout &lt;&lt; &quot;RUN: &quot; &lt;&lt; j &lt;&lt; &quot;:&quot; &lt;&lt; k &lt;&lt; std::endl &lt;&lt; std::endl;          delete p;     }         return 0; } <\/code><\/pre>\n<p>  \u041d\u043e \u0447\u0442\u043e \u0436\u0435 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>RunnableInterface<\/code>? \u0412\u0441\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438 \u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0432 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0446\u0435\u043b\u044f\u0445, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u042d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u0435\u0441\u043b\u0438 \u041e\u0421 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u043e, \u0447\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0432\u043c\u0435\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412 Windows, <code>GetModuleHandle()<\/code> <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms684229(v=vs.85).aspx\">\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442<\/a> \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044f. \u0422\u043e\u0433\u0434\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0434 Windows \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">class TestInterface  { private:     template &lt;typename T&gt;      static int Run_T(void* const pObj, int &k) { static_cast&lt;T*&gt;(pObj)-&gt;siRun(k); }     typedef void (*PFN_RUN_T)(void* const, int&);     CreateMemberFunctionChecker(siRun);     \/\/ Offset to static template member functions.     unsigned long m_ulRun_T_Offset; protected:     template &lt;typename T&gt;     void Init()      {         CheckMemberFunction(siRun, void (T::*)(int&));         char *pBaseOffset = (char*)GetModuleHandle(NULL);         m_ulRun_T_Offset = (unsigned long)&Run_T&lt;T&gt; - (unsigned long)pBaseOffset;     } public:     TestInterface(): m_ulRun_T_Offset(0) {}     void siRun(int &k)      {         assert(m_ulRun_T_Offset); \/\/ Make sure Init() was called.         char* const pBaseOffset = (char*)GetModuleHandle(NULL);         PFN_RUN_T pfnRun_T = (PFN_RUN_T)(pBaseOffset + m_ulRun_T_Offset);         (*pfnRun_T)(this, k);      }               virtual ~TestInterface() {} }; <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h4>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0432 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430\u0445 1, 2 \u0438 3 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u0432\u0441\u0451 \u0442\u043e, \u043e \u0447\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435: \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.<br \/>  \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d Qt Creator 5.0.2 \u0441 MinGW 4.7 x86 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432 Windows XP \u0438 Windows 7 x64.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/e92\/59a\/6eb\/e9259a6eb35be39caf7217ed69b4ecd9.jpg\"\/><\/p>\n<p>  \u0424\u0430\u0439\u043b testiface.h (\u043b\u0438\u0441\u0442\u0438\u043d\u0433 1) \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 TestInterface, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:  <\/p>\n<ul>\n<li>int siRun();<\/li>\n<li>void siReset(int &#038;k);<\/li>\n<li>void siSayHello();<\/li>\n<\/ul>\n<p>  <i><b>\u041b\u0418\u0421\u0422\u0418\u041d\u0413 1 \u2014 testiface.h<\/b><\/i>  <\/p>\n<pre><code class=\"cpp\">#ifndef TESTIFACE_H #define TESTIFACE_H   #include &lt;windows.h&gt; \/\/ for GetModuleHandle()   \/\/ Using the SFINAE (Substitution Failure Is Not An Error) technique, \/\/ the following macro creates a template class with typename T and a \/\/ static boolean member &quot;value&quot; that is set to true if the specified \/\/ member function exists in the T class. \/\/ This macro was created based on information that was retrieved from \/\/ the following URLs: \/\/ https:\/\/groups.google.com\/forum\/?fromgroups#!topic\/comp.lang.c++\/DAq3H8Ph_1k \/\/ http:\/\/objectmix.com\/c\/779528-call-member-function-only-if-exists-vc-9-a.html   #define CreateMemberFunctionChecker(FNNAME)                      template&lt;typename T&gt;  struct has_member_##FNNAME;                                                                                                  template&lt;typename R, typename C&gt;  class has_member_##FNNAME&lt;R C::*&gt;  {     private:                                                                  template&lt;R C::*&gt;     struct helper;                                        template&lt;typename T&gt;     static char check(helper&lt;&T::FNNAME&gt;*);           template&lt;typename T&gt;     static char (& check(...))[2];                public:                                                                   static const bool value = (sizeof(check&lt;C&gt;(0)) == sizeof(char));   }  #define CheckMemberFunction(FNNAME, FNPROTOTYPE)          { assert(has_member_##FNNAME&lt;FNPROTOTYPE&gt;::value); }   typedef int (*PFN_RUN_T)(void* const); typedef void (*PFN_RESET_T)(void* const, int&); typedef void (*PFN_SAYHELLO_T)(void* const);   #ifndef SINGLE_PROCESS class TestInterface  { private:     \/\/ Implement template functions.     template &lt;typename T&gt;      static int  Run_T(void* const pObj) { return static_cast&lt;T*&gt;(pObj)-&gt;siRun(); }     template &lt;typename T&gt;     static void Reset_T(void* const pObj, int &k) { static_cast&lt;T*&gt;(pObj)-&gt;siReset(k); }     template &lt;typename T&gt;     static void SayHello_T(void* const pObj) { static_cast&lt;T*&gt;(pObj)-&gt;siSayHello(); }      CreateMemberFunctionChecker(siRun);     CreateMemberFunctionChecker(siReset);     CreateMemberFunctionChecker(siSayHello);       \/\/ Offsets to static template member functions.     unsigned long m_ulRun_T_Offset, m_ulReset_T_Offset, m_ulSayHello_T_Offset; protected:     template &lt;typename T&gt;     void Init()      {         CheckMemberFunction(siRun, int (T::*)());         CheckMemberFunction(siReset, void (T::*)(int&));         CheckMemberFunction(siSayHello, void (T::*)());          char *pBaseOffset = (char*)GetModuleHandle(NULL);         m_ulRun_T_Offset = (unsigned long)&Run_T&lt;T&gt; - (unsigned long)pBaseOffset;         m_ulReset_T_Offset = (unsigned long)&Reset_T&lt;T&gt; - (unsigned long)pBaseOffset;         m_ulSayHello_T_Offset = (unsigned long)&SayHello_T&lt;T&gt; - (unsigned long)pBaseOffset;     } public:     TestInterface(): m_ulRun_T_Offset(0), m_ulReset_T_Offset(0), m_ulSayHello_T_Offset(0) {}     int siRun()      {         assert(m_ulRun_T_Offset); \/\/ Make sure Init() was called.         char *pBaseOffset = (char*)GetModuleHandle(NULL);         PFN_RUN_T pfnRun_T = (PFN_RUN_T)(pBaseOffset + m_ulRun_T_Offset);         return (*pfnRun_T)(this);      }     void siReset(int &k)      {         assert(m_ulReset_T_Offset); \/\/ Make sure Init() was called.         char *pBaseOffset = (char*)GetModuleHandle(NULL);         PFN_RESET_T pfnReset_T = (PFN_RESET_T)(pBaseOffset + m_ulReset_T_Offset);         (*pfnReset_T)(this, k);      }     void siSayHello()      {         assert(m_ulSayHello_T_Offset); \/\/ Make sure Init() was called.         char *pBaseOffset = (char*)GetModuleHandle(NULL);         PFN_SAYHELLO_T pfnSayHello_T = (PFN_SAYHELLO_T)(pBaseOffset + m_ulSayHello_T_Offset);         (*pfnSayHello_T)(this);      }     virtual ~TestInterface()  {} }; #else class TestInterface  { private:     template &lt;typename T&gt;      static int  Run_T(void* const pObj) { return static_cast&lt;T*&gt;(pObj)-&gt;siRun(); }     template &lt;typename T&gt;      static void Reset_T(void* const pObj, int &k) { static_cast&lt;T*&gt;(pObj)-&gt;siReset(k); }     template &lt;typename T&gt;      static void SayHello_T(void* const pObj) { static_cast&lt;T*&gt;(pObj)-&gt;siSayHello(); }          \/\/ Pointers to static template member functions.     PFN_RUN_T m_pfnRun_T;      PFN_RESET_T m_pfnReset_T;      PFN_SAYHELLO_T m_pfnSayHello_T;        CreateMemberFunctionChecker(siRun);     CreateMemberFunctionChecker(siReset);     CreateMemberFunctionChecker(siSayHello);  protected:     template &lt;typename T&gt;     void Init()      {         CheckMemberFunction(siRun, int (T::*)());         CheckMemberFunction(siReset, void (T::*)(int&));         CheckMemberFunction(siSayHello, void (T::*)());                  m_pfnRun_T = &Run_T&lt;T&gt;;         m_pfnReset_T = &Reset_T&lt;T&gt;;         m_pfnSayHello_T = &SayHello_T&lt;T&gt;;      } public:     TestInterface(): m_pfnRun_T(0), m_pfnReset_T(0), m_pfnSayHello_T(0) {}     int siRun()      {         assert(m_pfnRun_T); \/\/ Make sure Init() was called.         return (*m_pfnRun_T)(this);      }     void siReset(int &k)     {         assert(m_pfnReset_T); \/\/ Make sure Init() was called.         (*m_pfnReset_T)(this, k);      }     void siSayHello()      {         assert(m_pfnSayHello_T); \/\/ Make sure Init() was called.         (*m_pfnSayHello_T)(this);      }     virtual ~TestInterface() {} }; #endif \/\/ SINGLE_PROCESS #endif \/\/ TESTIFACE_H <\/code><\/pre>\n<p>  testclasses.h \u0438\u0437 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 2 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>Base<\/code> (\u043e\u0442 <code>TestInterface<\/code>), <code>DerivedOnce<\/code> (\u043e\u0442 <code>Base<\/code>) \u0438 <code>DerivedTwice<\/code> (\u043e\u0442<code> DerivedOnce<\/code>). \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>TestInterface::Init&lt;T&gt;()<\/code>, \u0433\u0434\u0435 <code>\u0422<\/code> \u2014 \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430. \u042d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <code>TestInterface()<\/code>. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>TestInterface<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0434\u0440\u0443\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a <code>siRun, siReset, siSayHello<\/code>, \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 <code>private\/protected<\/code>.<\/p>\n<p>  <i><b>\u041b\u0418\u0421\u0422\u0418\u041d\u0413 2 \u2014 testclasses.h<\/b><\/i>  <\/p>\n<pre><code class=\"cpp\">#ifndef TESTCLASSES_H #define TESTCLASSES_H   #ifndef TESTIFACE_H     #include &quot;testiface.h&quot; #endif   class Base: public TestInterface  {     friend class TestInterface; private:     int siRun() { return m_value; }     void siReset(int &k) { k = m_value*10; }     void siSayHello() { std::cout &lt;&lt; &quot;Hello from Base&quot; &lt;&lt; std::endl; }  protected:     int m_value; public:     Base(int value = 1): m_value(value) { TestInterface::Init&lt;Base&gt;(); } };  class DerivedOnce: public Base {     friend class TestInterface; private:     int siRun() { return m_value; }     void siReset(int &k) { k = m_value*100; }     void siSayHello() { std::cout &lt;&lt; &quot;Hello from DerivedOnce&quot; &lt;&lt; std::endl; }  public:     DerivedOnce(): Base() { TestInterface::Init&lt;DerivedOnce&gt;(); ++m_value; } };   class DerivedTwice: public DerivedOnce {     friend class TestInterface; private:     int siRun() { return m_value; }     void siReset(int &k) { k = m_value*1000; }     void siSayHello() { std::cout &lt;&lt; &quot;Hello from DerivedTwice&quot; &lt;&lt; std::endl; }  public:     DerivedTwice(): DerivedOnce() { TestInterface::Init&lt;DerivedTwice&gt;(); ++m_value; } };   #endif \/\/ TESTCLASSES_H <\/code><\/pre>\n<p>  \u0424\u0430\u0439\u043b main.cpp \u0438\u0437 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 3 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 WinAPI \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442:   <\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 <code>Base, DerivedOnce, DerivedTwice<\/code> \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 (owner)<\/li>\n<li>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (client)<\/li>\n<\/ol>\n<p>  \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0432 \u0446\u0438\u043a\u043b\u0435 \u043a \u043d\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u0430\u043a \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c <code>TestInterface*<\/code>, \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>siRun, siReset, siSayHello<\/code>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439; \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u00abOWNER\u00bb (\u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u0439) \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438; \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b; \u00abCLIENT\u00bb \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a \u0436\u0435 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0438 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0432\u044b\u0432\u043e\u0434 (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c.\u0431. \u0434\u0440\u0443\u0433\u0438\u043c), \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. <\/p>\n<p>  \u041f\u043e\u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>DerivedTwice::siSayHello()<\/code>, \u0437\u0430\u0442\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435 (\u0438\u0437-\u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <code>CheckMemberFunction(siSayHello, void (T::*)()) \u0432 TestInterface::Init&lt;T&gt;()<\/code>):  <\/p>\n<pre><code class=\"bash\">  Assertion failed!   Expression: has_member_siSayHello&lt;void (T::*)()&gt;::value <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 <code>siSayHello<\/code> \u0432 <code>DerivedTwice<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>double d<\/code>), \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 (\u0438\u0437-\u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <code>TestInterface::Init&lt;DerivedTwice&gt;()<\/code> \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 <code>DerivedTwice<\/code>):  <\/p>\n<pre><code class=\"bash\">  In instantiation of \u2018static void TestInterface::SayHello_T(void*) [with T = DerivedTwide]\u2019;   Required from \u2018void TestInterface::Init [with T = DerivedTwice] <\/code><\/pre>\n<p>  <i><b>\u041b\u0418\u0421\u0422\u0418\u041d\u0413 3 \u2014 main.cpp<\/b><\/i>  <\/p>\n<pre><code class=\"cpp\">#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;tchar.h&gt;   #include &lt;list&gt; #include &lt;iostream&gt; #include &lt;conio.h&gt; #include &lt;assert.h&gt;   #include &quot;testclasses.h&quot;   int main() {     const SIZE_T BufSize = 1024;     const TCHAR  szName[] = TEXT(&quot;Local\\\\SharedMemBlockObject&quot;);     const HANDLE hMapFile =              CreateFileMapping(                  INVALID_HANDLE_VALUE, \/\/ use paging file                  NULL,                 \/\/ default security                  PAGE_READWRITE,       \/\/ read\/write access                  0,                    \/\/ maximum object size (high-order DWORD)                  BufSize,              \/\/ maximum object size (low-order DWORD)                  szName );             \/\/ name of mapping object     if (hMapFile == NULL)      {         std::cout &lt;&lt; &quot;Could not create file mapping object (&quot; &lt;&lt; GetLastError() &lt;&lt; &quot;).\\n&quot; &lt;&lt; std::endl;         return 1;     }       const bool fFirstProcess = (GetLastError() != ERROR_ALREADY_EXISTS);     \/\/ Map the file to this process' address space.     const LPCTSTR pBuf =            (LPTSTR) MapViewOfFile(                                  hMapFile,            \/\/ handle to map object                                  FILE_MAP_ALL_ACCESS, \/\/ read\/write permission                                  0,                                  0,                                  BufSize );     if (pBuf == NULL)      {         std::cout &lt;&lt; &quot;Could not map view of file (&quot; &lt;&lt; GetLastError() &lt;&lt; &quot;).\\n&quot; &lt;&lt; std::endl;         CloseHandle( hMapFile );         return 1;     }      Base *pObj1;     DerivedOnce *pObj2;     DerivedTwice *pObj3;       char *pBuf1 = (char*)pBuf;     if (fFirstProcess)      {         std::cout &lt;&lt; &quot;OWNER PROCESS: &quot; &lt;&lt; std::endl;         \/\/ Create TestInterface objects in shared memory.         pObj1 = new(pBuf1)Base;        \/\/ first available memory addr         pBuf1 += sizeof(Base);        \/\/ skip to next available memory addr         pObj2 = new(pBuf1)DerivedOnce;         pBuf1 += sizeof(DerivedOnce); \/\/ skip to next available memory addr         pObj3 = new(pBuf1)DerivedTwice;     }     else      {         std::cout &lt;&lt; &quot;CLIENT PROCESS: &quot; &lt;&lt; std::endl;         \/\/ Access objects that are in shared memory.         pObj1 = (Base*)pBuf1;         \/\/ addr where Base obj was created         pBuf1 += sizeof(Base);         pObj2 = (DerivedOnce*)pBuf1;  \/\/ addr where DerivedOnce obj was created         pBuf1 += sizeof(DerivedOnce);         pObj3 = (DerivedTwice*)pBuf1; \/\/ addr where DerivedTwice obj was created     }       char szHexBuf[12];     sprintf(szHexBuf, &quot;0x%lx&quot;, (unsigned long) pBuf);     std::cout &lt;&lt; &quot;pBuf: &quot; &lt;&lt; szHexBuf &lt;&lt; std::endl &lt;&lt; std::endl;       \/\/ Place TestInterface* objects in a list.     std::list&lt;TestInterface*&gt; list1;     list1.insert(list1.end(), pObj1);     list1.insert(list1.end(), pObj2);     list1.insert(list1.end(), pObj3);        \/\/ Let TestInterface objects greet, run and reset generically.     std::list&lt;TestInterface*&gt;::iterator i;     for (i = list1.begin(); i != list1.end(); i++)      {         TestInterface* const p = *i;         p-&gt;siSayHello();         std::cout &lt;&lt; &quot;RUN:   &quot; &lt;&lt; p-&gt;siRun() &lt;&lt; std::endl;         int kk;         p-&gt;siReset( kk );         std::cout &lt;&lt; &quot;RESET: &quot; &lt;&lt; kk &lt;&lt; std::endl &lt;&lt; std::endl;     }       std::cout &lt;&lt; &quot;Press any key to end program&quot; &lt;&lt; std::endl;     if (fFirstProcess)         std::cout &lt;&lt; &quot; and destroy objects in shared memory&quot; &lt;&lt; std::endl;     std::cout &lt;&lt; &quot;...&quot; &lt;&lt; std::endl;       while (!kbhit())          Sleep(100);      if (fFirstProcess)      {         \/\/ Objects are no longer needed, call destructors.         for (i = list1.begin(); i != list1.end(); i++)          {             TestInterface* const p = *i;             \/\/ We need to call the destructor explicitly because             \/\/ the new with placement operator was used.             \/\/ We cannot call &quot;delete p;&quot;             p-&gt;~TestInterface();         }     }       UnmapViewOfFile(pBuf);     CloseHandle(hMapFile);       return 0; } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041d\u0430 \u043f\u0440\u0430\u0432\u0430\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041c\u0435\u0442\u043e\u0434, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0423\u0445\u043e\u0434 \u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f.   \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\/182824\/\"> http:\/\/habrahabr.ru\/post\/182824\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u043e\u0431\u0445\u043e\u0434\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-182824","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182824","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=182824"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182824\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}