{"id":268841,"date":"2015-11-24T06:30:02","date_gmt":"2015-11-24T03:30:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=268841"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=268841","title":{"rendered":"\u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 C++"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ef3\/519\/7e2\/ef35197e24db482dbb90df084b1ca883.png\" align=\"left\"\/> \u0412 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u044b\u0434\u0430\u043b\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0432\u0435\u0447\u0435\u0440, \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0433\u0434\u0430 \u0441\u0440\u043e\u0447\u043d\u044b\u0445 \u0434\u0435\u043b \u043d\u0435\u0442, \u0430 \u043d\u0435\u0441\u0440\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0435\u043d\u044c \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0434\u043b\u044f \u0434\u0443\u0448\u0438. \u0414\u043b\u044f \u0434\u0443\u0448\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u043e\u043a\u043b\u0430\u0434 <a href=\"https:\/\/github.com\/CppCon\/CppCon2015\">CppCon 2015<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430\u0437\u0430\u0434. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u044b \u0432\u0436\u0438\u0432\u0443\u044e \u0443 \u043c\u0435\u043d\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u043e \u0442\u0443\u0442 \u0432\u0441\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u0440\u043e\u0448\u0435\u043b \u043c\u0435\u0441\u044f\u0446, C++-17 \u0443\u0436\u0435 \u043d\u0430 \u043d\u043e\u0441\u0443 \u0438 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u043d\u043e \u043d\u0438\u043a\u0442\u043e \u0435\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043e \u043d\u0435\u0439 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b, \u0430 \u0442\u0443\u0442 \u0435\u0449\u0435 \u0438 \u0432\u0435\u0447\u0435\u0440 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439.\u0412 \u043e\u0431\u0449\u0435\u043c \u044f \u0431\u044b\u0441\u0442\u0440\u0435\u043d\u044c\u043a\u043e \u0442\u043a\u043d\u0443\u043b \u043c\u044b\u0448\u043a\u043e\u0439 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0448\u0438\u0439 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a: <a href=\"https:\/\/www.youtube.com\/watch?v=WjTrfoiB0MQ\">Andrei Alexandrescu \u201cDeclarative Control Flow&quot;<\/a> \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u043b \u0432\u0435\u0447\u0435\u0440. \u0410 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0445\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0432\u043e\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u043e\u043c.<a name=\"habracut\"><\/a><br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u043b\u044f C++ Explicit Flow Control, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043do \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0447\u0442\u043e \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u0430: \u043b\u0438\u0431\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043b\u0438\u0431\u043e \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, (\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 successful failure). \u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c boost::filesystem:<\/p>\n<pre><code>void copy_file_tr(const path& from, const path& to) {     path tmp=to+&quot;.deleteme&quot;;     try {         copy_file(from, tmp);         rename(tmp, to);     } catch(...) {         ::remove(tmp.c_str());         throw;     } } <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0431\u044b \u043d\u0438 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d, \u0447\u0442\u043e \u043d\u0430\u043c \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 try\/catch, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u044f\u0432\u043d\u043e \u043d\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0437\u0434\u0435\u0441\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f rename() \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0439 (\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439), \u0430 remove() \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 ( \u043f\u043e\u0447\u0435\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f ::remove() \u0432\u043c\u0435\u0441\u0442\u043e boost::filesystem::remove() ).\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0443\u0441\u0443\u0433\u0443\u0431\u0438\u043c \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0430\u0440\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e move_file_tr:<\/p>\n<pre><code>void move_file_tr(const path& from, const path& to) {     copy_file_tr(from, to);     try {         remove(from);     } catch(...) {         ::remove(to.c_str());         throw;     } } <\/code><\/pre>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432 \u0442\u0430\u043a\u043e\u043c \u043a\u0440\u043e\u0445\u043e\u0442\u043d\u043e\u043c \u043a\u0443\u0441\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d try\/catch \u0431\u043b\u043e\u043a. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u043e\u0445\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u0432\u0432\u043e\u0434\u0438\u0442 \u0441\u0432\u043e\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0442.\u0434. \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0432\u0441\u0435 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u043e, <a href=\"https:\/\/github.com\/isocpp\/CppCoreGuidelines\/blob\/master\/CppCoreGuidelines.md#Re-catch\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442<\/a> \u0441\u0432\u0435\u0441\u0442\u0438 \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0440\u0443\u0447\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 try\/catch, \u0438\u0431\u043e \u00abverbose and non-trivial uses error-prone\u00bb.\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u044f\u0432\u0438\u043c \u043f\u0440\u044f\u043c\u043e \u0438 \u0447\u0435\u0441\u0442\u043d\u043e \u0447\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e.<br \/>  \u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0446\u0435\u043b\u0435\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044e \u0441\u0432\u0435\u0434\u0435\u043d\u044b \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c\u0443 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443, \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u0435\u0437 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0448\u0430\u0433\u0430. \u042d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0437\u0432\u0443\u0447\u0430\u0442\u044c \u043a\u0430\u043a \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u043a\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u2014 \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0430\u0441 \u0438 \u043c\u044b \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u2014 SQL, make, regex, \u0432\u0441\u0435 \u043e\u043d\u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435. \u0427\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 C++ \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430?<br \/>  RAII \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0440\u0438\u0440\u043e\u0434\u0443 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u044f\u0432\u043d\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u043b\u0438\u0437\u043a\u0430\u044f \u0438\u0434\u0438\u043e\u043c\u0430 ScopeGuard. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043c\u0430\u043a\u0440\u043e\u0441 SCOPE_EXIT \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c ScopeGuard, \u044d\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0440\u044e\u043a, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 boost \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 1.38. \u0418 \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u044c \u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>namespace detail {     enum class ScopeGuardOnExit {};      template&lt;typename&lt;Fun&gt; ScopeGuard&lt;Fun&gt; operator+     (ScopeGuardOnExit, Fun&& fn) {         return ScopeGuard&lt;Fun&gt;(std::forward&lt;Fun&gt;(fn));     } }  #define SCOPE_EXIT \\     auto ANONIMOUS_VARIABLE(SCOPE_EXIT_STATE) \\     = ::detail::ScopeGuardOnExit + (&)[]  } <\/code><\/pre>\n<p>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0435\u043b\u043e \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435.<br \/>  \u0422\u0443\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f ScopeGuard, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043d\u043e \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d. (\u0412 \u043b\u0435\u0433\u043a\u0438\u0445 \u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f \u0432\u043e\u0437\u0434\u0443\u0445, \u0430 \u0442\u043e \u0431\u044b \u044f \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u043f\u0440\u0438\u0434\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u043b) <br \/>  \u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b, \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b:<\/p>\n<pre><code>#define CONACTENATE_IMPL(s1,s2) s1##s2 #define CONCATENATE(s1,s2) CONCATENATE_IMPL(s1,s2) #define ANONYMOUS_VARIABLE(str) CONCATENATE(str,__COUNTER__) <\/code><\/pre>\n<p>\u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 C++ \u043a\u043e\u0434 \u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u043d\u0435\u0432\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043e\u043c \u0447\u0435\u0440\u0442\u044b:<\/p>\n<pre><code>void fun() {     char name[] = &quot;\/tmp\/deleteme.XXXXXX&quot;;     auto fd = mkstemp(name);     SCOPE_EXIT { fclose(fd); unlink(name); };     auto buf = malloc(1024*1024);     SCOPE_EXIT { free(buf); };     ... } <\/code><\/pre>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0441\u0442\u0438\u043b\u044e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u2014 SCOPE_FAIL \u0438 SCOPE_SUCCESS, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0442\u043c\u043e\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0430. \u0418 \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0435\u0441\u0442\u044c \u0432 C++ \u2014 <i>bool uncaught_exception()<\/i>, \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <i>true<\/i> \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0438\u0437\u043d\u0443\u0442\u0440\u0438 catch \u0431\u043b\u043e\u043a\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043d\u044e\u0430\u043d\u0441 \u2014 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 C++ \u043f\u043e\u043b\u043e\u043c\u0430\u043d\u0430 \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u044b\u0437\u043e\u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0447\u0430\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u043c\u043e\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u0438\u043b\u0438 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043e\u0431\u044c\u0435\u043a\u0442 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 catch \u0431\u043b\u043e\u043a\u0430, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0437 <a href=\"https:\/\/isocpp.org\/files\/papers\/N4152.pdf\">\u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/a>. \u041a\u0430\u043a \u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e, \u0412 C++-17 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u044c\u044f\u0432\u043b\u0435\u043d\u0430 <i>deprecated<\/i> \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u2014 <i>int uncaught_exceptions()<\/i> (\u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438 \u0434\u0432\u0430 \u043e\u0442\u043b\u0438\u0447\u0438\u044f), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c SCOPE_SUCCESS \u0438\u043b\u0438 SCOPE_FAIL:<\/p>\n<pre><code>class UncaughtExceptionCounter {     int getUncaughtExceptionCount() noexcept;     int exceptionCount_; public:     UncaughtExceptionCounter()     : exceptionCount_(std::uncaught_exceptions()) {}          bool newUncaughtException() noexcept {         return std::uncaught_exceptions() &gt; exceptionCount_;     } }; <\/code><\/pre>\n<p>\u0417\u0430\u0431\u0430\u0432\u043d\u043e \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0441\u0430\u043c \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 RAII \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435. <br \/>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 \u043d\u0435\u0443\u0441\u043f\u0435\u0445\u0430:<\/p>\n<pre><code>template &lt;typename FunctionType, bool executeOnException&gt; class ScopeGuardForNewException {     FunctionType function_;     UncaughtExceptionCounter ec_;  public:     explicit ScopeGuardForNewException(const FunctionType& fn)     : function_(fn) {}      explicit ScopeGuardForNewException(FunctionType&& fn)     : function_(std::move(fn)) {}      ~ScopeGuardForNewException() noexcept(executeOnException) {         if (executeOnException == ec_.isNewUncaughtException()) {             function_();         }     } }; <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u043e \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0442\u043e\u0440. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0435\u0449\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u0430\u043a \u0442\u043e\u0442 \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437\u044f\u0449\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430: <i>noexcept(executeOnException)<\/i>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 SCOPE_FAIL \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c exception safe, \u0430 SCOPE_SUCCESS \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0447\u0438\u0441\u0442\u043e \u0438\u0437 \u0432\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u0438. \u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0434\u0435\u043b\u0430\u044e\u0442 C++ \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043b\u044e\u0431\u043b\u044e.<br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u043c, \u043f\u043e\u0434\u043e\u0431\u043d\u043e SCOPE_EXIT \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441:<\/p>\n<pre><code>enum class ScopeGuardOnFail {}; template &lt;typename FunctionType&gt; ScopeGuardForNewException&lt;     typename std::decay&lt;FunctionType&gt;::type, true&gt;     operator+(detail::ScopeGuardOnFail, FunctionType&& fn) {         return ScopeGuardForNewException&lt;             typename std::decay&lt;FunctionType&gt;::type, true         &gt;(std::forward&lt;FunctionType&gt;(fn));     }  #define SCOPE_FAIL \\     auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) \\     = ::detail::ScopeGuardOnFail() + [&]() noexcept <\/code><\/pre>\n<p>\u0418 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f SCOPE_EXIT <br \/>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n<pre><code>void copy_file_tr(const path& from, const path& to) {     bf::path t = to.native() + &quot;.deleteme&quot;;     SCOPE_FAIL { ::remove(t.c_str()); };     bf::copy_file(from, t);     bf::rename(t, to); }  void move_file_tr(const path& from, const path& to) {     bf::copy_file_transact(from, to);     SCOPE_FAIL { ::remove(to.c_str()); };     bf::remove(from); } <\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0447\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442. \u0410 \u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SCOPE_SUCCESS, \u0437\u0430\u043e\u0434\u043d\u043e \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u0440\u043e\u0441\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>int string2int(const string& s) {     int r;     SCOPE_SUCCESS { assert(int2string(r) == s); };     ...     return r; } <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0430\u0440\u044c\u0435\u0440\u0447\u0438\u043a \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0438\u0434\u0438\u043e\u043c\u0430\u043c C++ \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u2014 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043b\u0438\u0446\u0430<\/h3>\n<p> \u0412\u0441\u0435 \u044d\u0442\u043e \u043d\u0430\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u044b\u0441\u043b\u0438 \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0436\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u0434\u0430\u043b\u0435\u043a\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u041c\u043d\u0435 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0440\u043e\u0441\u0438\u043b\u043e\u0441\u044c \u0432 \u0433\u043b\u0430\u0437\u0430 \u0442\u043e \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043d\u043e\u0432\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, SCOPE_EXIT \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 boost.1.38, \u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0434\u0435\u0441\u044f\u0442\u044c \u043b\u0435\u0442, \u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0435\u0441\u043a\u0443 \u043e ScopeGuard \u0432\u044b\u0448\u043b\u0430 \u0432 Dr.Dobbs \u0430\u0436 \u0432 2000\u043c \u0433\u043e\u0434\u0443. \u0425\u043e\u0447\u0443 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0447\u0442\u043e \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0435\u0441\u043a\u0443 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0432\u0438\u0434\u0446\u0430 \u0438 \u043f\u0440\u043e\u0440\u043e\u043a\u0430, \u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u0438\u043c \u043a\u0430\u043a \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Loki \u043b\u0435\u0433\u043b\u0430 \u0432 \u043e\u0441\u043d\u043e\u0432\u0443 boost::mpl, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0448\u043b\u0430 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0438 \u0435\u0449\u0435 \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0434\u0430\u043b\u0430 \u0438\u0434\u0438\u043e\u043c\u044b \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u0430\u043c \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0435\u0441\u043a\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u0430 D \u0433\u0434\u0435 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u2014 <i>scope exit, scope success and scope failure<\/i> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u044f\u0437\u044b\u043a\u0430 \u0438 \u0434\u0430\u0432\u043d\u043e \u0437\u0430\u043d\u044f\u043b\u0438 \u0432 \u043d\u0435\u043c \u043f\u0440\u043e\u0447\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e. <br \/>  \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u0434\u043e\u043a\u043b\u0430\u0434 \u042d\u0440\u0438\u043a\u0430 \u041d\u0438\u0431\u043b\u0435\u0440\u0430 \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0430\u043c\u043e\u0439 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/CppCon\/CppCon2015\/tree\/master\/Keynotes\/Ranges%20for%20the%20Standard%20Library\">Ranges for the Standard Library<\/a>. \u0425\u043e\u0447\u0443 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0447\u0442\u043e ranges \u2014 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u044f\u0437\u044b\u043a\u0430 D, \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441\u0430\u043c \u0434\u043e\u043a\u043b\u0430\u0434 \u2014 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 (\u0441 D \u043d\u0430 C++) \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 H.S.Teoh <a href=\"http:\/\/wiki.dlang.org\/Component_programming_with_ranges\">Component programming with ranges<\/a>.<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0445\u043e\u0436\u0435 \u0447\u0442\u043e C++ \u043d\u0430\u0447\u0430\u043b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043f\u0440\u043e\u0447\u0435\u043c \u043e\u043d \u0441\u0430\u043c \u0436\u0435 \u0438 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0433\u0440\u044f\u0434\u0443\u0449\u0438\u0439 C++-17 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0443\u0440\u043e\u043a\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438, \u0441\u0435\u043c\u043d\u0430\u0434\u0446\u0430\u0442\u044b\u0439 \u0433\u043e\u0434 \u0441\u043a\u0443\u0447\u043d\u044b\u043c \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442, \u0437\u0430\u043f\u0430\u0441\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043f\u043a\u043e\u0440\u043d\u043e\u043c, \u0430\u043d\u0430\u043d\u0430\u0441\u0430\u043c\u0438 \u0438 \u0440\u044f\u0431\u0447\u0438\u043a\u0430\u043c\u0438.<\/p>\n<h3>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/h3>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u0441\u0442.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=WjTrfoiB0MQ\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0443\u0434\u0438\u043e \u0434\u043e\u043a\u043b\u0430\u0434<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/CppCon\/CppCon2015\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b CppCon 2015<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/CppCon\/CppCon2015\/blob\/master\/Presentations\/Declarative%20Control%20Flow\/Declarative%20Control%20Flow%20-%20Andrei%20Alexandrescu%20-%20CppCon%202015.pdf\">\u0421\u043b\u0430\u0439\u0434\u044b \u043a \u0434\u043e\u043a\u043b\u0430\u0434\u0443 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0435\u0441\u043a\u0443<\/a><\/li>\n<li><a href=\"http:\/\/www.drdobbs.com\/cpp\/generic-change-the-way-you-write-excepti\/184403758?pgno=2\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043e ScopeGuard 2000\u0433<\/a><\/li>\n<li><a href=\"http:\/\/www.boost.org\/doc\/libs\/1_38_0\/libs\/scope_exit\/doc\/html\/index.html\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e boost::ScopeExit<\/a><\/li>\n<li><a href=\"https:\/\/isocpp.org\/files\/papers\/N4152.pdf\">\u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Herb Sutter \u043f\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e uncaught_exception()<\/a><\/li>\n<li><a href=\"http:\/\/wiki.dlang.org\/Component_programming_with_ranges\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e ranges \u0432 D<\/a>, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043d\u0435\u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430<\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/270545\/\"> http:\/\/habrahabr.ru\/post\/270545\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ef3\/519\/7e2\/ef35197e24db482dbb90df084b1ca883.png\" align=\"left\"\/> \u0412 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u044b\u0434\u0430\u043b\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0432\u0435\u0447\u0435\u0440, \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0433\u0434\u0430 \u0441\u0440\u043e\u0447\u043d\u044b\u0445 \u0434\u0435\u043b \u043d\u0435\u0442, \u0430 \u043d\u0435\u0441\u0440\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0435\u043d\u044c \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0434\u043b\u044f \u0434\u0443\u0448\u0438. \u0414\u043b\u044f \u0434\u0443\u0448\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u043e\u043a\u043b\u0430\u0434 <a href=\"https:\/\/github.com\/CppCon\/CppCon2015\">CppCon 2015<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430\u0437\u0430\u0434. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u044b \u0432\u0436\u0438\u0432\u0443\u044e \u0443 \u043c\u0435\u043d\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u043e \u0442\u0443\u0442 \u0432\u0441\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u0440\u043e\u0448\u0435\u043b \u043c\u0435\u0441\u044f\u0446, C++-17 \u0443\u0436\u0435 \u043d\u0430 \u043d\u043e\u0441\u0443 \u0438 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u043d\u043e \u043d\u0438\u043a\u0442\u043e \u0435\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043e \u043d\u0435\u0439 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b, \u0430 \u0442\u0443\u0442 \u0435\u0449\u0435 \u0438 \u0432\u0435\u0447\u0435\u0440 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439.\u0412 \u043e\u0431\u0449\u0435\u043c \u044f \u0431\u044b\u0441\u0442\u0440\u0435\u043d\u044c\u043a\u043e \u0442\u043a\u043d\u0443\u043b \u043c\u044b\u0448\u043a\u043e\u0439 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0448\u0438\u0439 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a: <a href=\"https:\/\/www.youtube.com\/watch?v=WjTrfoiB0MQ\">Andrei Alexandrescu \u201cDeclarative Control Flow&quot;<\/a> \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u043b \u0432\u0435\u0447\u0435\u0440. \u0410 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0445\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0432\u043e\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u043e\u043c.<\/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-268841","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268841","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=268841"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268841\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}