{"id":166589,"date":"2013-01-22T11:29:03","date_gmt":"2013-01-22T07:29:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=166589"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=166589","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c function<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u043e\u0434 \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/159389\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0442\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u044b, \u043a\u0430\u043a <i>function<\/i> \u0432 C++, \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 function \u0438 \u0437\u0430\u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443<\/h2>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0434\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0443: <i>\u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0432\u044b\u0437\u043e\u0432\u0430<\/i>. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0437\u043e\u0432\u0430, \u0440\u0435\u0447\u044c \u043f\u0440\u043e <i>this<\/i>, \u0447\u0442\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<br \/>  \u041f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0440\u043e\u0434\u0435 <a href=\"http:\/\/www.boost.org\/doc\/libs\/1_52_0\/doc\/html\/function.html\">boost<\/a>, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430, \u043a\u0430\u043a \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u043f\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u044b\u0437\u043e\u0432\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043b\u0435\u0436\u0430\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u044b, \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u044e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b. \u0422\u0430\u043a\u0438\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u044b \u0438 \u0434\u0430\u0436\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b, \u043d\u043e, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u043a\u043e\u0434\u0430. \u041f\u0443\u0441\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432 \u0447\u0435\u043c-\u0442\u043e \u043f\u0440\u043e\u0449\u0435, \u043e\u0431\u043b\u0430\u0434\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u043a\u0430\u043a, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430.<\/p>\n<h2>\u041c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044e \u043f\u043e\u0438\u0441\u043a\u0430<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438: \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0443\u0435\u043c\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u044b\u0437\u043e\u0432\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0437\u043e\u0432\u0430. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0438\u0437 <a href=\"http:\/\/habrahabr.ru\/post\/159389\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>, \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c, \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043f\u043e\u0434\u0434\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e? \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0442\u0435\u0440\u044f\u0435\u0442 \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435. \u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u043c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u0443\u0434\u0430-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043e\u0434\u0435 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u0432\u044b\u0437\u043e\u0432\u0430, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u0435\u0440\u0432\u0430\u044f \u043c\u044b\u0441\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u043a\u043e\u0439 <i>function<\/i>, \u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438?.. \u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0432\u043d\u0443\u0442\u0440\u0438 <i>function<\/i> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0435\u0440\u0432\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <abbr title=\"placement new\">\u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043c\u0435\u0441\u0442\u0443<\/abbr>, \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435, \u043d\u043e \u2014 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<h2>\u0421\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044f\u0437\u044b\u043a C++11. \u041a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d \u0432 \u0441\u0440\u0435\u0434\u0435 <abbr title=\"Apple clang version 4.1 (tags\/Apple\/clang-421.11.66) (based on LLVM 3.1svn)\">Xcode 4.5.2<\/abbr>. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f C++11 \u0432 Visual Studio 2012 \u0437\u0430\u043f\u0430\u0437\u0434\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2012\/11\/02\/visual-c-c-11-and-the-future-of-c.aspx\">November 2012 Compiler CTP<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438, \u0445\u043e\u0442\u044f \u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0435\u0447\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442. \u0412 \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0440\u0435\u0432\u0435\u0440\u0430\u043d\u0441\u044b \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 VS2012 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f C++03 \u0446\u0435\u043d\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043c\u0430 \u043a\u043e\u0434\u0430, \u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430.<br \/>  \u041d\u0430\u0447\u043d\u0443 \u0441 \u043a\u043e\u043d\u0446\u0430. \u041a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &quot;function.hpp&quot;  int foo(int v) {     std::cout &lt;&lt; &quot;foo: &quot; &lt;&lt; v &lt;&lt; std::endl;     return v; }  struct bar {     int baz(int v)     {         std::cout &lt;&lt; &quot;bar::baz: &quot; &lt;&lt; v &lt;&lt; std::endl;         return v;     } };  int main() {     \/\/ \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u0430 \u0442\u0438\u043f\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0432\u044b\u0437\u043e\u0432\u0430     typedef bc::function&lt;int (int)&gt; function_ptr;     std::vector&lt;function_ptr&gt; functions;      \/\/ \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439     functions.push_back(BC_BIND(&foo));      \/\/ \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439-\u0447\u043b\u0435\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f     bar obj;     functions.push_back(BC_BIND(&bar::baz, &obj));      int i = 0, c = 0;     for (auto f : functions)         c += f ? f(++i) : 0;      std::cout &lt;&lt; &quot;result: &quot; &lt;&lt; c &lt;&lt; std::endl; }<\/code><\/pre>\n<p>  \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u043d\u0438\u043c \u2014 \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0418\u0437-\u0437\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0438 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 \u2014 <i>BC_BIND<\/i>. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0434\u0438\u043d \u0438 \u0434\u0432\u0430, \u043d\u043e \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e, \u043e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u044d\u043b\u043b\u0438\u043f\u0441\u0438\u0441, \u0447\u0442\u043e \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0430\u0433\u0438\u0435\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0435 \u0431\u0443\u0434\u0443 \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u0435\u0435, \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e Visual C++ \u0438 \u0442\u0443\u0442 \u043f\u0440\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u0441\u043e\u0431\u044b\u043c \u0432\u0438\u0434\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0438 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u0435\u0433\u043e \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0447\u0443\u0442\u043e\u0447\u043a\u0443 \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f.<br \/>  \u041f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443. \u041a\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b, \u0434\u0430 \u0435\u0449\u0435 \u0431\u0435\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439? \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044e. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0445\u043e\u0442\u044f \u0431\u044b POSIX <a href=\"http:\/\/pubs.opengroup.org\/onlinepubs\/9699919799\/functions\/V2_chap02.html#tag_15_12_03\">\u0442\u0440\u0435\u0431\u0443\u0435\u0442<\/a> \u0438\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a <i>void*<\/i> \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043d\u0435\u0442. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u044b\u0445\u043e\u0434 \u0435\u0441\u0442\u044c. \u041f\u0443\u0441\u0442\u044c \u0441\u043f\u0435\u043a\u0442\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0432\u044b\u0437\u043e\u0432\u0430, \u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code>function&lt;return_type (...)&gt; function_ptr;   return_type free_function(...);  class Class {     return_type member_function(...); };<\/code><\/pre>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u043d\u043e \u043d\u0435\u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434:  <\/p>\n<pre><code>return_type member_function_wrapper(Class *context, ...) {     return context-&gt;member_function(...); }<\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u043b\u0443\u0447\u0448\u0435. \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f:  <\/p>\n<pre><code>return_type free_function_wrapper(void *unused, ...) {     return free_function(...); }  return_type member_function_wrapper(void *context, ...) {     return static_cast&lt;Class*&gt;(context)-&gt;member_function(...); }<\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043e\u0431\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, <i>free_function_wrapper<\/i> \u0438 <i>member_function_wrapper<\/i> \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443. \u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e, \u0442\u043e \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u0435\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043b\u0430\u0441\u0441\u0435 \u0438 \u0441\u0430\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0447\u043b\u0435\u043d. \u0418 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043d\u043e \u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043e\u0442\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code>#include &lt;iostream&gt;  struct bar {     int baz(int v)     {         std::cout &lt;&lt; &quot;bar::baz: &quot; &lt;&lt; v &lt;&lt; std::endl;         return v;     } };   template &lt;typename Class, int (Class::*MemberFunctionPtr)(int)&gt; int function_wrapper(void *self, int v) {     return (static_cast&lt;Class*&gt;(self)-&gt;*MemberFunctionPtr)(v); }   int main() {     typedef int (*function_ptr)(void*, int);     function_ptr f = &function_wrapper&lt;bar, &bar::baz&gt;;       bar obj;     int const i = f(&obj, 1);      std::cout &lt;&lt; &quot;result: &quot; &lt;&lt; i &lt;&lt; std::endl; }<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 <i>function<\/i> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u043e\u0441\u0442\u043e <i>NULL<\/i>. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u2014 \u043f\u043e-\u043c\u043e\u0435\u043c\u0443, \u0437\u0434\u043e\u0440\u043e\u0432\u043e.<br \/>  \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0445\u0438\u0434\u0435\u0440\u0430 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430. \u041f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430. \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <abbr title=\"variadic templates\">\u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/abbr> \u0438\u0437 C++11 \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0430 \u0421++03.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">function.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#pragma once  \/\/#define BC_NO_EXCEPTIONS   #include &lt;utility&gt; #include &lt;functional&gt;   #define BC_SUBST(Arg)                           Arg  #define BC_BIND_DISAMBIGUATE2(has_args, ...)    BC_SUBST(BC_BIND_ ## has_args (__VA_ARGS__)) #define BC_BIND_DISAMBIGUATE(has_args, ...)     BC_BIND_DISAMBIGUATE2(has_args, __VA_ARGS__)  #define BC_HAS_ARGS_IMPL(TWO, ONE, N, ...)      N #define BC_HAS_ARGS(...)                        BC_SUBST(BC_HAS_ARGS_IMPL(__VA_ARGS__, 2, 1, ERROR))  #define BC_BIND(...)                            BC_BIND_DISAMBIGUATE(BC_HAS_ARGS(__VA_ARGS__), __VA_ARGS__)  #define BC_BIND_1(fp)                           bc::detail::bind&lt;decltype(fp), fp&gt;() #define BC_BIND_2(mf, ip)                       bc::detail::bind&lt;decltype(mf), mf&gt;(ip)   namespace bc \/\/ bicycle {          template &lt;typename Signature&gt;     class function;       namespace detail     {                  template &lt;typename Signature&gt;         struct function_traits;                  template &lt;typename ReturnType, typename ...ArgumentTypes&gt;         struct function_traits&lt;ReturnType (*)(ArgumentTypes...)&gt;         {             \/\/typedef ReturnType (*Signature)(ArgumentTypes...); \/\/ MS error C3522: parameter pack cannot be expanded in this context             typedef function&lt;ReturnType (ArgumentTypes...)&gt; function_type;                          template &lt;typename Signature, Signature fp&gt;             static ReturnType wrapper(void const *, ArgumentTypes&& ... args)             {                 return (*fp)(std::forward&lt;ArgumentTypes&gt;(args)...);             }         };                           template &lt;typename ReturnType, typename Class, typename ...ArgumentTypes&gt;         struct function_traits&lt;ReturnType (Class::*)(ArgumentTypes...)&gt;         {             \/\/typedef ReturnType (Class::*Signature)(ArgumentTypes...); \/\/ MS error C3522: parameter pack cannot be expanded in this context             typedef Class *                                 class_ptr;                         typedef function&lt;ReturnType (ArgumentTypes...)&gt; function_type;                          template &lt;typename Signature, Signature mf&gt;             static ReturnType wrapper(const void *ip, ArgumentTypes&& ... args)             {                 Class* instance = const_cast&lt;Class*&gt;(static_cast&lt;Class const *&gt;(ip));                 return (instance-&gt;*mf)(std::forward&lt;ArgumentTypes&gt;(args)...);             }         };                           template &lt;typename ReturnType, typename Class, typename ...ArgumentTypes&gt;         struct function_traits&lt;ReturnType (Class::*)(ArgumentTypes...) const&gt;         {             \/\/typedef ReturnType (Class::*Signature)(ArgumentTypes...) const; \/\/ MS error C3522: parameter pack cannot be expanded in this context             typedef const Class *                           class_ptr;             typedef function&lt;ReturnType (ArgumentTypes...)&gt; function_type;                          template &lt;typename Signature, Signature mf&gt;             static ReturnType wrapper(void const *ip, ArgumentTypes&& ... args)             {                 Class const *instance = static_cast&lt;Class const *&gt;(ip);                 return (instance-&gt;*mf)(std::forward&lt;ArgumentTypes&gt;(args)...);             }         };                           \/\/ bind free function         template &lt;typename Signature, Signature fp&gt;         typename function_traits&lt;Signature&gt;::function_type bind()         {             typedef function_traits&lt;Signature&gt; traits;             return typename traits::function_type(&traits::template wrapper&lt;Signature, fp&gt;, 0);         }                   \/\/ bind member function         template &lt;typename Signature, Signature mf&gt;         typename function_traits&lt;Signature&gt;::function_type bind(typename function_traits&lt;Signature&gt;::class_ptr ip)         {             typedef function_traits&lt;Signature&gt; traits;             return typename traits::function_type(&traits::template wrapper&lt;Signature, mf&gt;, ip);         }      }       template &lt;typename ReturnType, typename ...ArgumentTypes&gt;     class function&lt;ReturnType (ArgumentTypes...)&gt;     {         typedef ReturnType (*StaticFuncPtr)(void const*, ArgumentTypes&& ...);              public:         function() : func_(0), data_(0) {}         function(StaticFuncPtr f, void const *d) : func_(f), data_(d) {}                  ReturnType operator () (ArgumentTypes... args) const         { #ifndef BC_NO_EXCEPTIONS             if (!func_)                 throw std::bad_function_call(); #endif \/\/ BC_NO_EXCEPTIONS             return (*func_)(data_, std::forward&lt;ArgumentTypes&gt;(args)...);         }          explicit operator bool() const         {             return 0 != func_;         }          bool operator == (function const &other) const         {             return func_ == other.func_  &&  data_ == other.data_;         }                  bool operator != (function const &other) const         {             return !(*this == other);         }              private:         StaticFuncPtr   func_;         void const     *data_;     };  }<\/code><\/pre>\n<\/div>\n<\/div>\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\/166589\/\"> http:\/\/habrahabr.ru\/post\/166589\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u043e\u0434 \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/159389\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0442\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u044b, \u043a\u0430\u043a <i>function<\/i> \u0432 C++, \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.  <\/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-166589","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/166589","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=166589"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/166589\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=166589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=166589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=166589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}