{"id":288469,"date":"2018-08-24T13:40:02","date_gmt":"2018-08-24T09:40:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288469"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2018-08-24T09:40:02","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288469","title":{"rendered":"RPC \u2014 \u043f\u043e\u0432\u043e\u0434 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0432 C++ 14 \/ 17"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/421001\/\" class=\"post__text post__text-html js-mediator-article\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/r5\/fg\/-w\/r5fg-wsld9ujbwxghq54s-kpaso.jpeg\" width=\"250\" height=\"180\" align=\"left\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0430 C++ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++ 11, \u043f\u0440\u0438\u043d\u0435\u0441\u0448\u0438\u0439 \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e. \u0418 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445. \u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a C++ 14 \u0438 17 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043d\u0435\u0442 \u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0444\u0438\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b. \u0412\u0435\u0441\u043d\u043e\u0439 \u044f \u0432\u0441\u0435 \u0436\u0435 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u0430 \u044f\u0437\u044b\u043a\u0430 \u0438 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0443. \u0414\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c. \u0420\u0435\u0448\u0435\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0435 RPC \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 \u0432\u0441\u0435 \u043d\u0430 C++. \u042d\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  \u0418\u0434\u0435\u044f, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0444\u0438\u0434\u0431\u044d\u043a \u0441 Reddit, \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u2014 \u0432\u0441\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0441\u043d\u043e\u0439, \u043d\u0430\u0447\u0430\u043b\u0435 \u043b\u0435\u0442\u0430. \u041a \u043a\u043e\u043d\u0446\u0443 \u0436\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440.<\/p>\n<p>  \u0412\u044b \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0438\u0441\u044c \u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c RPC? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0441\u0442\u0430 \u0412\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0446\u0435\u043b\u044c\u044e, \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u2026<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  RPC (remote procedure call) \u2014 \u0442\u0435\u043c\u0430 \u043d\u0435 \u043d\u043e\u0432\u0430\u044f. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0438\u0434\u044b \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430. \u0412\u0441\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0443\u043d\u043a\u0442\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \/ \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/li>\n<li>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<\/li>\n<li>\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/li>\n<\/ul>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0439 \u0446\u0435\u043b\u044c\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0446\u0435\u043b\u044c\u044e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u0444\u043e\u0440\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0426\u0435\u043b\u0438 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0435\u2026 \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u0430 \u0438 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h1>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h1>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 RPC \u043d\u0430 C++ 14 \/ 17, \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0430\u043a\u0446\u0435\u043d\u0442\u044b \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u0430 \u044f\u0437\u044b\u043a\u0430, \u0441\u0442\u0430\u0432\u0448\u0438\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d \u0432 \u0441\u0432\u043e\u0435\u043c RPC, \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430, \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u043f\u044b\u0442\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0438\u0445\u0441\u044f \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<\/p>\n<h2>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<ul>\n<li>\u0412\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0440\u0442\u0435\u0436.<\/li>\n<li>\u0421\u0430\u043c\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/li>\n<li>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0434\u043e\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0443\u0444\u0435\u0440, \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d<\/li>\n<\/ul>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043a\u043e\u0434 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">string_serializer<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">namespace rpc::type { using buffer = std::vector&lt;char&gt;; }   \/\/ namespace rpc::type  namespace rpc::packer {  class string_serializer final { public:     template &lt;typename ... T&gt;     type::buffer save(std::tuple&lt;T ... &gt; const &amp;tuple) const     {         auto str = to_string(tuple, std::make_index_sequence&lt;sizeof ... (T)&gt;{});         return {begin(str), end(str)};     }      template &lt;typename ... T&gt;     void load(type::buffer const &amp;buffer, std::tuple&lt;T ... &gt; &amp;tuple) const     {         std::string str{begin(buffer), end(buffer)};         from_string(std::move(str), tuple, std::make_index_sequence&lt;sizeof ... (T)&gt;{});     }  private:     template &lt;typename T, std::size_t ... I&gt;     std::string to_string(T const &amp;tuple, std::index_sequence&lt;I ... &gt;) const     {         std::stringstream stream;          auto put_item = [&amp;stream] (auto const &amp;i)         {             if constexpr (std::is_same_v&lt;std::decay_t&lt;decltype(i)&gt;, std::string&gt;)                 stream &lt;&lt; std::quoted(i) &lt;&lt; ' ';             else                 stream &lt;&lt; i &lt;&lt; ' ';         };          (put_item(std::get&lt;I&gt;(tuple)), ... );         return std::move(stream.str());     }      template &lt;typename T, std::size_t ... I&gt;     void from_string(std::string str, T &amp;tuple, std::index_sequence&lt;I ... &gt;) const     {         std::istringstream stream{std::move(str)};          auto get_item = [&amp;stream] (auto &amp;i)         {             if constexpr (std::is_same_v&lt;std::decay_t&lt;decltype(i)&gt;, std::string&gt;)                 stream &gt;&gt; std::quoted(i);             else                 stream &gt;&gt; i;         };          (get_item(std::get&lt;I&gt;(tuple)), ... );     } };  }   \/\/ namespace rpc::packer <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0418 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f main<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">int main() {     try     {         std::tuple args{10, std::string{\"Test string !!!\"}, 3.14};         rpc::packer::string_serializer serializer;         auto pack = serializer.save(args);         std::cout &lt;&lt; \"Pack data: \" &lt;&lt; std::string{begin(pack), end(pack)} &lt;&lt; std::endl;         decltype(args) params;         serializer.load(pack, params);          \/\/ For test         {             auto pack = serializer.save(params);             std::cout &lt;&lt; \"Deserialized pack: \" &lt;&lt; std::string{begin(pack), end(pack)} &lt;&lt; std::endl;         }     }     catch (std::exception const &amp;e)     {         std::cerr &lt;&lt; \"Error: \" &lt;&lt; e.what() &lt;&lt; std::endl;         return EXIT_FAILURE;     }     return EXIT_SUCCESS; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <b>\u0420\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u0446\u0435\u043d\u0442\u043e\u0432.<\/b><\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0435\u0441\u044c \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438  <\/p>\n<pre><code class=\"cpp\">namespace rpc::type { using buffer = std::vector&lt;char&gt;; }   \/\/ namespace rpc::type <\/code><\/pre>\n<p>  \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440 (save) \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0435\u0433\u043e \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 (load) <\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 save \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0443\u0444\u0435\u0440.  <\/p>\n<pre><code class=\"cpp\">template &lt;typename ... T&gt; type::buffer save(std::tuple&lt;T ... &gt; const &amp;tuple) const {     auto str = to_string(tuple, std::make_index_sequence&lt;sizeof ... (T)&gt;{});     return {begin(str), end(str)}; } <\/code><\/pre>\n<p>  \u041a\u043e\u0440\u0442\u0435\u0436 \u2014 \u0448\u0430\u0431\u043b\u043e\u043d \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432 C++11 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0435\u0431\u044f \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0438. \u0417\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430. \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 C++ 14 \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432). \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0442\u0438\u043f make_index_sequence, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c  <\/p>\n<pre><code class=\"cpp\">template&lt; class T, T... Ints &gt; class integer_sequence;  template&lt;class T, T N&gt; using make_integer_sequence = std::integer_sequence&lt;T, \/* a sequence 0, 1, 2, ..., N-1 *\/ &gt;; template&lt;std::size_t N&gt; using make_index_sequence = make_integer_sequence&lt;std::size_t, N&gt;; <\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0430 C++11, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043d\u043e\u0441\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  \u0422\u0430\u043a\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u00ab\u043f\u0440\u043e\u0439\u0442\u0438\u00bb \u043f\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0443  <\/p>\n<pre><code class=\"cpp\">template &lt;typename T, std::size_t ... I&gt; std::string to_string(T const &amp;tuple, std::index_sequence&lt;I ... &gt;) const {     std::stringstream stream;      auto put_item = [&amp;stream] (auto const &amp;i)     {         if constexpr (std::is_same_v&lt;std::decay_t&lt;decltype(i)&gt;, std::string&gt;)             stream &lt;&lt; std::quoted(i) &lt;&lt; ' ';         else             stream &lt;&lt; i &lt;&lt; ' ';     };      (put_item(std::get&lt;I&gt;(tuple)), ... );     return std::move(stream.str()); } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 to_string \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432 C++.<\/p>\n<p>  <b>\u0420\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u0446\u0435\u043d\u0442\u043e\u0432<\/b><br \/>  \u0412 C++ 14 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c auto \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u042d\u0442\u043e\u0433\u043e \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>  \u0412 C++ 17 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c <b>\u00ab\u0441\u0432\u0435\u0440\u0442\u043a\u0430\u00bb<\/b>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">(put_item(std::get&lt;I&gt;(tuple)), ... ); <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f put_item \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0430\u044f \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0427\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043d\u0430 C++ 11  <\/p>\n<pre><code class=\"cpp\">template &lt;typename \u2026 T&gt; void unused(T &amp;&amp; \u2026 ) {} \/\/ ... unused(put_item(std::get&lt;I&gt;(tuple)) ... ); <\/code><\/pre>\n<p>  \u041d\u043e \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0431\u044b\u043b\u0438 \u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e \u0431\u044b \u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 C++ 17 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0430\u043b\u0438\u0430\u0441\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, decay_t, \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0430  <\/p>\n<pre><code class=\"cpp\">typename decay&lt;T&gt;::type <\/code><\/pre>\n<p>  \u0416\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0431\u044b\u0442\u044c. \u0428\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u0433\u0434\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430-\u0442\u0440\u043e\u0439\u043a\u0430 typename \u0438 template, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f\u043c\u0438 \u0438 \u0443\u0433\u043b\u043e\u0432\u044b\u043c\u0438 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0436\u0443\u0442\u043a\u043e\u0432\u0430\u0442\u043e. \u0427\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0443\u0433\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u0431\u0435\u0449\u0430\u044e\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0441\u0442, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u044c template, typename.<\/p>\n<p>  \u0421\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0435 \u043a \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043b\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u044f\u0437\u044b\u043a\u0430 \u00abif constexpr\u00bb, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041c\u043d\u043e\u0433\u0438\u0445 \u0443\u0447\u0438\u043b\u0438, \u0447\u0442\u043e switch \u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \/ \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0441 \u0434\u043e\u0432\u043e\u0434\u0430\u043c\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u00ab\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430\u00bb. \u0410 \u0442\u0443\u0442 \u00abif constexpr\u00bb\u2026 \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0432\u043d\u043e\u0434\u0443\u0448\u043d\u044b\u043c\u0438 \u043a \u043d\u0435\u0439. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u044f\u0437\u044b\u043a\u0430 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0432 \u043f\u043e\u0442\u043e\u043a \u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f std::quoted. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u0442\u043e\u043a \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0440\u043e\u043a\u0438, \u043d\u0435 \u0434\u0443\u043c\u0430\u044f \u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435.<\/p>\n<p>  \u0421 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. \u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f (load) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e.<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442<\/h2>\n<p>  \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0441\u0442. \u042d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0431\u0443\u0444\u0435\u0440.  <\/p>\n<pre><code class=\"cpp\">namespace rpc::type { \/\/ ... using executor = std::function&lt;buffer (buffer)&gt;; }   \/\/ namespace rpc::type <\/code><\/pre>\n<p>  \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u00ab\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e std::bind, \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0442.\u00a0\u0434. \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430. \u0414\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442. \u041c\u043e\u0436\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e RPC, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043d\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<h2>\u041a\u043b\u0438\u0435\u043d\u0442<\/h2>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041a\u043b\u0438\u0435\u043d\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0410 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0438\u0435\u043d\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">namespace rpc {  template &lt;typename TPacker&gt; class client final { private:     class result;  public:     client(type::executor executor)         : executor_{executor}     {     }      template &lt;typename ... TArgs&gt;     result call(std::string const &amp;func_name, TArgs &amp;&amp; ... args)     {         auto request = std::make_tuple(func_name, std::forward&lt;TArgs&gt;(args) ... );         auto pack = packer_.save(request);         auto responce = executor_(std::move(pack));         return {responce};     }  private:     using packer_type = TPacker;      packer_type packer_;     type::executor executor_;      class result final     {     public:         result(type::buffer buffer)             : buffer_{std::move(buffer)}         {         }          template &lt;typename T&gt;         auto as() const         {             std::tuple&lt;std::decay_t&lt;T&gt;&gt; tuple;             packer_.load(buffer_, tuple);             return std::move(std::get&lt;0&gt;(tuple));         }      private:         packer_type packer_;         type::buffer buffer_;     }; };  }   \/\/ namespace rpc <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041a\u043b\u0438\u0435\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0432\u0438\u0434\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442-\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c. \u0418\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430, \u0438 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0434\u0430 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u0412 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.  <\/p>\n<pre><code class=\"cpp\">auto executor = [] (rpc::type::buffer buffer) {     \/\/ Print request data     std::cout &lt;&lt; \"Request pack: \" &lt;&lt; std::string{begin(buffer), end(buffer)} &lt;&lt; std::endl;     return buffer; }; <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0442\u043a\u0443\u0434\u0430.<\/p>\n<p>  <b>\u041c\u0435\u0442\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 call:<\/b><\/p>\n<ul>\n<li>\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/li>\n<li>\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442<\/li>\n<li>\u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/li>\n<\/ul>\n<p>  \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0433\u043e\u0442\u043e\u0432\u0430. \u0427\u0442\u043e-\u0442\u043e \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c. \u041e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<h2>\u0421\u0435\u0440\u0432\u0435\u0440<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0431\u0435\u0433\u043b\u043e, \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430 \u2014 \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0430\u044f \u0431\u0443\u0444\u0435\u0440 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;cstdint&gt; #include &lt;cstdlib&gt; #include &lt;functional&gt; #include &lt;iomanip&gt; #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;sstream&gt; #include &lt;string&gt; #include &lt;tuple&gt; #include &lt;vector&gt; #include &lt;utility&gt;  namespace rpc::type {  using buffer = std::vector&lt;char&gt;; using executor = std::function&lt;buffer (buffer)&gt;;  }   \/\/ namespace rpc::type  namespace rpc::detail {  template &lt;typename&gt; struct function_meta;  template &lt;typename TRes, typename ... TArgs&gt; struct function_meta&lt;std::function&lt;TRes (TArgs ... )&gt;&gt; {     using result_type = std::decay_t&lt;TRes&gt;;     using args_type = std::tuple&lt;std::decay_t&lt;TArgs&gt; ... &gt;;     using request_type = std::tuple&lt;std::string, std::decay_t&lt;TArgs&gt; ... &gt;; };  }   \/\/ namespace rpc::detail  namespace rpc::packer {  class string_serializer final { public:     template &lt;typename ... T&gt;     type::buffer save(std::tuple&lt;T ... &gt; const const &amp;tuple) const     {         auto str = to_string(tuple, std::make_index_sequence&lt;sizeof ... (T)&gt;{});         return {begin(str), end(str)};     }      template &lt;typename ... T&gt;     void load(type::buffer const &amp;buffer, std::tuple&lt;T ... &gt; &amp;tuple) const     {         std::string str{begin(buffer), end(buffer)};         from_string(std::move(str), tuple, std::make_index_sequence&lt;sizeof ... (T)&gt;{});     }  private:     template &lt;typename T, std::size_t ... I&gt;     std::string to_string(T const &amp;tuple, std::index_sequence&lt;I ... &gt;) const     {         std::stringstream stream;          auto put_item = [&amp;stream] (auto const &amp;i)         {             if constexpr (std::is_same_v&lt;std::decay_t&lt;decltype(i)&gt;, std::string&gt;)                 stream &lt;&lt; std::quoted(i) &lt;&lt; ' ';             else                 stream &lt;&lt; i &lt;&lt; ' ';         };          (put_item(std::get&lt;I&gt;(tuple)), ... );         return std::move(stream.str());     }      template &lt;typename T, std::size_t ... I&gt;     void from_string(std::string str, T &amp;tuple, std::index_sequence&lt;I ... &gt;) const     {         std::istringstream stream{std::move(str)};          auto get_item = [&amp;stream] (auto &amp;i)         {             if constexpr (std::is_same_v&lt;std::decay_t&lt;decltype(i)&gt;, std::string&gt;)                 stream &gt;&gt; std::quoted(i);             else                 stream &gt;&gt; i;         };          (get_item(std::get&lt;I&gt;(tuple)), ... );     } };  }   \/\/ namespace rpc::packer  namespace rpc {  template &lt;typename TPacker&gt; class client final { private:     class result;  public:     client(type::executor executor)         : executor_{executor}     {     }      template &lt;typename ... TArgs&gt;     result call(std::string const &amp;func_name, TArgs &amp;&amp; ... args)     {         auto request = std::make_tuple(func_name, std::forward&lt;TArgs&gt;(args) ... );         auto pack = packer_.save(request);         auto responce = executor_(std::move(pack));         return {responce};     }  private:     using packer_type = TPacker;      packer_type packer_;     type::executor executor_;      class result final     {     public:         result(type::buffer buffer)             : buffer_{std::move(buffer)}         {         }          template &lt;typename T&gt;         auto as() const         {             std::tuple&lt;std::decay_t&lt;T&gt;&gt; tuple;             packer_.load(buffer_, tuple);             return std::move(std::get&lt;0&gt;(tuple));         }      private:         packer_type packer_;         type::buffer buffer_;     }; };  template &lt;typename TPacker&gt; class server final { public:     template &lt;typename ... THandler&gt;     server(std::pair&lt;char const *, THandler&gt; const &amp; ... handlers)     {         auto make_executor = [&amp;packer = packer_] (auto const &amp;handler)         {             auto executor = [&amp;packer, function = std::function{handler}] (type::buffer buffer)             {                 using meta = detail::function_meta&lt;std::decay_t&lt;decltype(function)&gt;&gt;;                 typename meta::request_type request;                 packer.load(buffer, request);                  auto response = std::apply([&amp;function] (std::string const &amp;, auto &amp;&amp; ... args)                         { return function(std::forward&lt;decltype(args)&gt;(args) ... ); },                         std::move(request)                     );                  return packer.save(std::make_tuple(std::move(response)));             };              return executor;         };          (handlers_.emplace(handlers.first, make_executor(handlers.second)), ... );     }      type::buffer execute(type::buffer buffer)     {         std::tuple&lt;std::string&gt; pack;         packer_.load(buffer, pack);         auto func_name = std::move(std::get&lt;0&gt;(pack));         auto const iter = handlers_.find(func_name);         if (iter == end(handlers_))             throw std::runtime_error{\"Function \\\"\" + func_name + \"\\\" not found.\"};         return iter-&gt;second(std::move(buffer));     }  private:     using packer_type = TPacker;     packer_type packer_;      using handlers_type = std::map&lt;std::string, type::executor&gt;;     handlers_type handlers_; };  }   \/\/ namespace rpc  int main() {     try     {         using packer_type = rpc::packer::string_serializer;          rpc::server&lt;packer_type&gt; server{             std::pair{\"hello\",                 [] (std::string const &amp;s)                 {                     std::cout &lt;&lt; \"Func: \\\"hello\\\". Inpur string: \" &lt;&lt; s &lt;&lt; std::endl;                     return \"Hello \" + s + \"!\";                 }},             std::pair{\"to_int\",                 [] (std::string const &amp;s)                 {                     std::cout &lt;&lt; \"Func: \\\"to_int\\\". Inpur string: \" &lt;&lt; s &lt;&lt; std::endl;                     return std::stoi(s);                 }}         };          auto executor = [&amp;server] (rpc::type::buffer buffer)         {             return server.execute(std::move(buffer));         };          rpc::client&lt;packer_type&gt; client{std::move(executor)};         std::cout &lt;&lt; client.call(\"hello\", std::string{\"world\"}).as&lt;std::string&gt;() &lt;&lt; std::endl;         std::cout &lt;&lt; \"Convert to int: \" &lt;&lt; client.call(\"to_int\", std::string{\"100500\"}).as&lt;int&gt;() &lt;&lt; std::endl;     }     catch (std::exception const &amp;e)     {         std::cerr &lt;&lt; \"Error: \" &lt;&lt; e.what() &lt;&lt; std::endl;         return EXIT_FAILURE;     }     return EXIT_SUCCESS; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u044d\u0442\u043e \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u043c\u0435\u0442\u043e\u0434 execute.<\/p>\n<p>  <b>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 server<\/b>  <\/p>\n<pre><code class=\"cpp\">template &lt;typename ... THandler&gt; server(std::pair&lt;char const *, THandler&gt; const &amp; ... handlers) {     auto make_executor = [&amp;packer = packer_] (auto const &amp;handler)     {         auto executor = [&amp;packer, function = std::function{handler}] (type::buffer buffer)         {             using meta = detail::function_meta&lt;std::decay_t&lt;decltype(function)&gt;&gt;;             typename meta::request_type request;             packer.load(buffer, request);             auto response = std::apply([&amp;function] (std::string const &amp;, auto &amp;&amp; ... args)                     { return function(std::forward&lt;decltype(args)&gt;(args) ... ); },                     std::move(request)                 );             return packer.save(std::make_tuple(std::move(response)));         };         return executor;     };     (handlers_.emplace(handlers.first, make_executor(handlers.second)), ... ); } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c. \u041d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440. \u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u0440\u0430 \u2014 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 server \u0441\u0440\u0430\u0437\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u0427\u0442\u043e \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0418 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043e \u0442\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 server \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0438 \u043d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>  <b>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 server<\/b>  <\/p>\n<pre><code class=\"cpp\">template &lt;typename ... THandler&gt; server(std::pair&lt;char const *, THandler&gt; const &amp; ... handlers) {      \/\/ \u2026      (handlers_.emplace(handlers.first, make_executor(handlers.second)), ... ); } <\/code><\/pre>\n<p>  \u041f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0432 \u043a\u0430\u0440\u0442\u0443 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0430\u043a \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u0435\u0440\u0442\u043a\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 std::map \u0432\u0441\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0431\u0435\u0437 \u0446\u0438\u043a\u043b\u043e\u0432 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432  <\/p>\n<pre><code class=\"cpp\">(handlers_.emplace(handlers.first, make_executor(handlers.second)), ... ); <\/code><\/pre>\n<p>  \u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c auto \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0430\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438. \u041e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0440\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (std::map). \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u0435, \u0438 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u041f\u043e\u044f\u0432\u0438\u0432\u0448\u0430\u044f\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f std::apply \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u044e std::apply \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0430 C++11. \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0435\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  <b>\u041c\u0435\u0442\u043e\u0434 execute<\/b><\/p>\n<pre><code class=\"cpp\">type::buffer execute(type::buffer buffer) {     std::tuple&lt;std::string&gt; pack;     packer_.load(buffer, pack);     auto func_name = std::move(std::get&lt;0&gt;(pack));     auto const iter = handlers_.find(func_name);     if (iter == end(handlers_))         throw std::runtime_error{\"Function \\\"\" + func_name + \"\\\" not found.\"};     return iter-&gt;second(std::move(buffer)); } <\/code><\/pre>\n<p>  \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u043c\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u043a\u0430\u0440\u0442\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0432 \u043e\u0431\u0435\u0440\u0442\u043a\u0430\u0445 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 server. \u041a\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0410 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f?\u00bb. \u0414\u0430, \u0432 \u043f\u043e\u043b\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435, \u043c\u0430\u0440\u0448\u0430\u043b\u0438\u043d\u0433 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d. \u0422\u0443\u0442 \u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">main<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">int main() {     try     {         using packer_type = rpc::packer::string_serializer;          rpc::server&lt;packer_type&gt; server{             std::pair{\"hello\",                 [] (std::string const &amp;s)                 {                     std::cout &lt;&lt; \"Func: \\\"hello\\\". Inpur string: \" &lt;&lt; s &lt;&lt; std::endl;                     return \"Hello \" + s + \"!\";                 }},             std::pair{\"to_int\",                 [] (std::string const &amp;s)                 {                     std::cout &lt;&lt; \"Func: \\\"to_int\\\". Inpur string: \" &lt;&lt; s &lt;&lt; std::endl;                     return std::stoi(s);                 }}         };          auto executor = [&amp;server] (rpc::type::buffer buffer)         {             return server.execute(std::move(buffer));         };          rpc::client&lt;packer_type&gt; client{std::move(executor)};         std::cout &lt;&lt; client.call(\"hello\", std::string{\"world\"}).as&lt;std::string&gt;() &lt;&lt; std::endl;         std::cout &lt;&lt; \"Convert to int: \" &lt;&lt; client.call(\"to_int\", std::string{\"100500\"}).as&lt;int&gt;() &lt;&lt; std::endl;     }     catch (std::exception const &amp;e)     {         std::cerr &lt;&lt; \"Error: \" &lt;&lt; e.what() &lt;&lt; std::endl;         return EXIT_FAILURE;     }     return EXIT_SUCCESS; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0412 \u043d\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0417\u0430\u043c\u0435\u043d\u0438\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e executor, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 C++ 17 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u043f\u0440\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (std::pair \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0430) \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>  \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f RPC \u0433\u043e\u0442\u043e\u0432\u0430. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<h2>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u043e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a. \u041c\u043d\u043e\u0433\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0414\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u044b\u0432\u043e\u0434\u0430. \u041a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043d\u0443\u0436\u0435\u043d \u0441\u0432\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0432\u043e\u0434\u0430. \u0418\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u043b\u0435 \u0432 \u043f\u043e\u0442\u043e\u043a, \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0412 \u044d\u0442\u043e\u043c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f. \u0415\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0432 C++. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u043c\u0435\u0441\u0438 \u0438\u0437 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u041d\u043e \u0438\u0434\u0435\u044f \u0431\u044b\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c C++.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0432 C++ \u043f\u043e\u043a\u0430 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0435 \u043d\u0438\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 C++ 17 \u00abstructured bindings\u00bb. \u0427\u0430\u0441\u0442\u043e \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0436\u0430\u0440\u0433\u043e\u043d\u0438\u0437\u043c\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0442 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c.<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436 \u043f\u043e\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445.  <\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; auto to_tuple(T &amp;&amp;value) {     using type = std::decay_t&lt;T&gt;;      if constexpr (is_braces_constructible_v&lt;type, dummy_type, dummy_type, dummy_type&gt;)     {         auto &amp;&amp;[f1, f2, f3] = value;         return std::make_tuple(f1, f2, f3);     }     else if constexpr (is_braces_constructible_v&lt;type, dummy_type, dummy_type&gt;)     {         auto &amp;&amp;[f1, f2] = value;         return std::make_tuple(f1, f2);     }     else if constexpr (is_braces_constructible_v&lt;type, dummy_type&gt;)     {         auto &amp;&amp;[f1] = value;         return std::make_tuple(f1);     }     else     {         return std::make_tuple();     } } <\/code><\/pre>\n<p>  \u0412 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041e \u043c\u043d\u043e\u0433\u043e\u043c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043a\u0440\u043e\u043c\u0435 structured bindings. \u0424\u0443\u043d\u043a\u0446\u0438\u044f to_tuple \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439, \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e structured bindings \u00ab\u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u00bb \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u043a\u043e\u0440\u0442\u0435\u0436. \u0410 \u00abif constexpr\u00bb \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0442\u0432\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 C++ \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043d\u0435\u0442, \u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0432\u0441\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0442\u0438\u043f\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f. \u0415\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b. \u041e\u0434\u043d\u043e \u0438\u0437 \u043d\u0438\u0445 \u2014 \u0442\u0438\u043f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  \u0412 to_tuple \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f is_braces_constructible_v. \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">is_braces_constructible_v<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct dummy_type final {     template &lt;typename T&gt;     constexpr operator T () noexcept     {         return *static_cast&lt;T const *&gt;(nullptr);     } };  template &lt;typename T, typename ... TArgs&gt; constexpr decltype(void(T{std::declval&lt;TArgs&gt;() ... }), std::declval&lt;std::true_type&gt;()) is_braces_constructible(std::size_t) noexcept;  template &lt;typename, typename ... &gt; constexpr std::false_type is_braces_constructible(...) noexcept;  template &lt;typename T, typename ... TArgs&gt; constexpr bool is_braces_constructible_v = std::decay_t&lt;decltype(is_braces_constructible&lt;T, TArgs ... &gt;(0))&gt;::value; <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f to_tuple \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0435\u0445 \u043f\u043e\u043b\u0435\u0439. \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u00ab\u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c\u044b\u0445\u00bb \u043f\u043e\u043b\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u043b\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0442\u043a\u0438 \u00abif constexpr\u00bb \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u0443\u043c\u0430, \u0438\u043b\u0438 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0435 \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 boost.preprocessor. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c \u0438 \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u043b\u0435\u0439.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f to_tuple \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e boost.preprocessor<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template &lt;typename T&gt; auto to_tuple(T &amp;&amp;value) {     using type = std::decay_t&lt;T&gt;;  #define NANORPC_TO_TUPLE_LIMIT_FIELDS 64 \/\/ you can try to use BOOST_PP_LIMIT_REPEAT  #define NANORPC_TO_TUPLE_DUMMY_TYPE_N(_, n, data) \\     BOOST_PP_COMMA_IF(n) data  #define NANORPC_TO_TUPLE_PARAM_N(_, n, data) \\     BOOST_PP_COMMA_IF(n) data ## n  #define NANORPC_TO_TUPLE_ITEM_N(_, n, __) \\     if constexpr (is_braces_constructible_v&lt;type, \\     BOOST_PP_REPEAT_FROM_TO(0, BOOST_PP_SUB(NANORPC_TO_TUPLE_LIMIT_FIELDS, n), NANORPC_TO_TUPLE_DUMMY_TYPE_N, dummy_type) \\     &gt;) { auto &amp;&amp;[ \\     BOOST_PP_REPEAT_FROM_TO(0, BOOST_PP_SUB(NANORPC_TO_TUPLE_LIMIT_FIELDS, n), NANORPC_TO_TUPLE_PARAM_N, f) \\     ] = value; return std::make_tuple( \\     BOOST_PP_REPEAT_FROM_TO(0, BOOST_PP_SUB(NANORPC_TO_TUPLE_LIMIT_FIELDS, n), NANORPC_TO_TUPLE_PARAM_N, f) \\     ); } else  #define NANORPC_TO_TUPLE_ITEMS(n) \\     BOOST_PP_REPEAT_FROM_TO(0, n, NANORPC_TO_TUPLE_ITEM_N, nil)      NANORPC_TO_TUPLE_ITEMS(NANORPC_TO_TUPLE_LIMIT_FIELDS)     {         return std::make_tuple();     }  #undef NANORPC_TO_TUPLE_ITEMS #undef NANORPC_TO_TUPLE_ITEM_N #undef NANORPC_TO_TUPLE_PARAM_N #undef NANORPC_TO_TUPLE_DUMMY_TYPE_N #undef NANORPC_TO_TUPLE_LIMIT_FIELDS } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 boost.bind \u0434\u043b\u044f C++ 03, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f to_tuple \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c boost.preprocessor \u043d\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0439.<\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f to_tuple \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0441\u0432\u043e\u0435\u043c RPC.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 C++ \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0432\u043e\u0434 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d. \u0416\u0435\u043b\u0430\u043d\u0438\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u043c\u0443 \u043e\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 C++ \u0442\u0430\u043a\u0438\u0445, \u043a\u0430\u043a std::list, std::vector, std::map. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0440\u043e SFINAE \u0438 std::enable_if_t \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a-\u0442\u043e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432, \u043f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 is_braces_constructible_v.<\/p>\n<h1>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  \u0417\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u043f\u043e\u0441\u0442\u0430 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043c\u0430\u0440\u0448\u0430\u043b\u0438\u043d\u0433 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f stl-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u0414\u0430\u0431\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043f\u043e\u0441\u0442 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0432\u043e\u044e RPC \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 C++ 14 \/ 17. \u0410 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c HTTP \/ HTTPS \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041a\u043e\u0434 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/tdv\/nanorpc\">NanoRPC \u043d\u0430 GitHub <\/a>.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/421001\/\"> https:\/\/habr.com\/post\/421001\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/421001\/\" class=\"post__text post__text-html js-mediator-article\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/r5\/fg\/-w\/r5fg-wsld9ujbwxghq54s-kpaso.jpeg\" width=\"250\" height=\"180\" align=\"left\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0430 C++ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++ 11, \u043f\u0440\u0438\u043d\u0435\u0441\u0448\u0438\u0439 \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e. \u0418 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445. \u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a C++ 14 \u0438 17 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043d\u0435\u0442 \u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0444\u0438\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b. \u0412\u0435\u0441\u043d\u043e\u0439 \u044f \u0432\u0441\u0435 \u0436\u0435 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u0430 \u044f\u0437\u044b\u043a\u0430 \u0438 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0443. \u0414\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c. \u0420\u0435\u0448\u0435\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0435 RPC \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 \u0432\u0441\u0435 \u043d\u0430 C++. \u042d\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  \u0418\u0434\u0435\u044f, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0444\u0438\u0434\u0431\u044d\u043a \u0441 Reddit, \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u2014 \u0432\u0441\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0441\u043d\u043e\u0439, \u043d\u0430\u0447\u0430\u043b\u0435 \u043b\u0435\u0442\u0430. \u041a \u043a\u043e\u043d\u0446\u0443 \u0436\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440.<\/p>\n<p>  \u0412\u044b \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0438\u0441\u044c \u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c RPC? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0441\u0442\u0430 \u0412\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0446\u0435\u043b\u044c\u044e, \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u2026  <\/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-288469","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288469","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=288469"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288469\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}