{"id":263765,"date":"2015-08-18T12:37:02","date_gmt":"2015-08-18T08:37:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263765"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263765","title":{"rendered":"\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0432 \u0421++, \u0447\u0430\u0441\u0442\u044c 3: \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u044b (Iterable)"},"content":{"rendered":"<p>       \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u0430\u0445 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043e\u043f\u0438\u0448\u0443 \u0432\u0430\u043c \u043c\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u044f \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432:<\/p>\n<ul>\n<li>\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0433\u0435\u043d\u0435\u0440\u044f\u0442 \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u0434<\/li>\n<li>\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u0430\u0431\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u0447\u0435\u043c \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b<\/li>\n<li>\u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0442<\/li>\n<li>\u0438\u0445 \u0442\u0440\u0443\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/li>\n<li>\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438, \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 difference_type<\/li>\n<\/ul>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0440\u0443\u0434\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0451.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430. \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 C++ \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u044e\u0434\u0443, \u043d\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u2013 \u044d\u0442\u043e \u043d\u0435\u0447\u0442\u043e, \u0438\u0437 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c begin \u0438 end, \u043f\u0430\u0440\u0443 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u0434\u043e end \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u0447\u0430\u0432 \u0441 begin. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">using std::begin; using std::end;   template&lt;typename T&gt; using Iterator_type =     decltype(begin(std::declval&lt;T&gt;()));   template&lt;typename T&gt; concept bool Range =     requires(T range) {         { begin(range) } -&gt; Iterator_type&lt;T&gt;;         { end(range) }  -&gt; Iterator_type&lt;T&gt;;         requires Iterator&lt;Iterator_type&lt;T&gt;&gt;;     }; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 Range, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f InputRange, ForwardRange, \u0438 \u0442.\u0434. \u041d\u0430 \u0434\u0435\u043b\u0435 \u043e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442 \u0441\u0432\u043e\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u041d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u0441\u044f \u044d\u0442\u0430 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c08\/f6b\/ae8\/c08f6bae8ddb569fab87f5d9f40331bc.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Boost.Range (http:\/\/www.boost.org\/libs\/range)<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 1: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u043a\u0430\u043a \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u0435\u043c, \u0442\u0430\u043a \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445, \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u044b \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 end \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u043c. \u0418 \u0442\u0430\u043a\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 <i>\u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e<\/i>, \u0447\u0435\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e, \u043a\u0430\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 + 1\u00bb \u2013 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u0433\u0434\u0435 \u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442\u0435 \u0435\u0451. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0438\u043f \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0443 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u043c. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<h2>\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u043e\u0432 (Iterable)<\/h2>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b? \u041c\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0445, \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c, \u0442\u0430\u043a \u0432\u0435\u0434\u044c? \u0410 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c? \u041d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e. \u0415\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c, \u0442.\u043a. \u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 + 1\u00bb. \u041d\u043e \u0435\u0433\u043e <i>\u043c\u043e\u0436\u043d\u043e<\/i> \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2013 \u0441\u043b\u0430\u0431\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440.<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439. \u041d\u043e \u043e\u043d \u0438\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0422\u0430\u043a \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u2013 <i>\u043f\u0443\u0441\u0442\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/i>.<\/p>\n<p>  \u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f Range \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b begin \u0438 end \u0431\u044b\u043b\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c\u0438, \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u0430\u0431\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u2013 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f Iterable. \u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u044b \u2013 \u043e\u043d\u0438 \u043a\u0430\u043a \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0443 begin \u0438 end \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b. \u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">template&lt;typename T&gt; using Sentinel_type =     decltype(end(std::declval&lt;T&gt;()));   template&lt;typename T&gt; concept bool Iterable =     requires(T range) {         { begin(range) } -&gt; Iterator_type&lt;T&gt;;         { end(range) }  -&gt; Sentinel_type&lt;T&gt;;         requires Iterator&lt;Iterator_type&lt;T&gt;&gt;;         requires EqualityComparable&lt;             Iterator_type&lt;T&gt;, Sentinel_type&lt;T&gt;&gt;;     };   template&lt;typename T&gt; concept bool Range =     Iteratable&lt;T&gt; &&     Same&lt;Iterator_type&lt;T&gt;, Sentinel_type&lt;T&gt;&gt;; <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f Range \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e Iterable. \u041e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0442\u043e\u0447\u043d\u044f\u0435\u0442 \u0435\u0451, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 begin \u0438 end.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/14e\/f71\/2c4\/14ef712c4656831e0c80fe9c345b79b9.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u044b \u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u0445 \u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u00ab\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u00bb \u2013 \u0442.\u0435., \u0441\u0445\u043e\u0436\u0435\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432 begin \u0438 end, \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u0430 \u0441\u0438\u043b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 begin. \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u043a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 RandomAccessRange, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c requires RandomAccessIterable &#038;&#038; Range \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e.<\/p>\n<p>  \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, BidirectionalIterable \u0438 ForwardIterable \u0432 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c begin \u0438\u0437 Iterable. <\/p>\n<h2>Iterable \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b STL<\/h2>\n<p>  \u041d\u043e \u043f\u043e\u0441\u0442\u043e\u0439\u0442\u0435 \u2013 \u0432\u0435\u0434\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b STL \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u0430\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0443 begin \u0438 end \u0431\u044b\u043b\u043e \u043e\u0434\u0438\u043d \u0442\u0438\u043f. \u0422\u0430\u043a \u0438 \u0435\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u043e\u0448\u0435\u0440\u0441\u0442\u0438\u043b \u0432\u0435\u0441\u044c STL, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, std::find   <\/p>\n<pre><code class=\"cpp\">template&lt;class InputIterator, class Value&gt; InputIterator find(InputIterator first, InputIterator last,      Value const & value) {     for (; first != last; ++first)         if (*first == value)             break;     return first; } <\/code><\/pre>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 std::find \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Ranges. \u041d\u043e \u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 end. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 Iterables \u0432\u043c\u0435\u0441\u0442\u043e Ranges:<\/p>\n<pre><code class=\"cpp\">template&lt;class InputIterator, class Sentinel, class Value&gt; InputIterator find(InputIterator first, Sentinel last,      Value const & value) {     for (; first != last; ++first)         if (*first == value)             break;     return first; } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451 \u2013 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u043b\u043e\u0435, \u0447\u0442\u043e \u0435\u0433\u043e \u0434\u0430\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b C++98 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u0438\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Iterables \u0432\u043c\u0435\u0441\u0442\u043e Ranges? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435. \u041b\u0435\u0433\u0447\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0434\u0434\u0430\u044e\u0442\u0441\u044f. \u042d\u0442\u043e:<\/p>\n<ul>\n<li>copy_backward<\/li>\n<li>\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430\u043c\u0438 (push_heap, pop_heap, make_heap, sort_heap)<\/li>\n<li>inplace_merge<\/li>\n<li>nth_element<\/li>\n<li>partial_sort \u0438 partial_sort_copy<\/li>\n<li>next_permutation \u0438 prev_permutation<\/li>\n<li>random_shuffle<\/li>\n<li>reverse \u0438 reverse_copy<\/li>\n<li>sort \u0438 stable_sort<\/li>\n<li>stable_partition<\/li>\n<\/ul>\n<p>  \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u0441\u043e\u0442\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0447\u0438\u0441\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e Iterable \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 Range, \u043c\u044b \u0434\u0430\u0451\u043c \u043b\u044e\u0431\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0441 Iterable, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0441 Ranges. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438 \u0432\u0430\u0436\u043d\u043e \u2013 \u0434\u043b\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0438\u0445 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e.<\/p>\n<h2>\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0432 Perf<\/h2>\n<p>  \u0418 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c? \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0438\u043c \u0421-\u0441\u0442\u0440\u043e\u043a\u0430\u043c. \u042f \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u043b\u0430\u0441\u0441 c_string_range \u0438 \u043d\u0430\u0448\u0451\u043b, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0442 \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u0434. \u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043d\u043e\u0432\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 range_facade, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c Iterable \u0432\u043c\u0435\u0441\u0442\u043e Range.<\/p>\n<pre><code class=\"cpp\">using namespace ranges; struct c_string_iterable   : range_facade&lt;c_string_iterable&gt; { private:     friend range_core_access;     char const *sz_;     char const & current() const { return *sz_; }     void next() { ++sz_; }     bool done() const { return *sz_ == 0; }     bool equal(c_string_iterable const &that) const     { return sz_ == that.sz_; } public:     c_string_iterable(char const *sz)         : sz_(sz) {} }; <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0439. \u0412\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 range_facade. \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e, \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u043b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 c_string_range, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u2013 \u043d\u043e\u0432\u044b\u0439 c_string_iterable:<\/p>\n<pre><code class=\"cpp\">\/\/ Range-based int range_strlen(     c_string_range::iterator begin,     c_string_range::iterator end) {     int i = 0;     for(; begin != end; ++begin)         ++i;     return i; }  \/\/ Iterable-based int iterable_strlen(     range_iterator_t&lt;c_string_iterable&gt; begin,     range_sentinel_t&lt;c_string_iterable&gt; end) {     int i = 0;     for(; begin != end; ++begin)         ++i;     return i; } <\/code><\/pre>\n<p>  \u0414\u0430\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u044f \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443.<\/p>\n<table>\n<tr>\n<td>\n<pre><code>;Range-based strlen pushl    %ebp     movl    %esp, %ebp     pushl    %esi     leal    8(%ebp), %ecx     movl    12(%ebp), %esi     xorl    %eax, %eax     testl    %esi, %esi     movl    8(%ebp), %edx     jne    LBB2_4     jmp    LBB2_1     .align    16, 0x90 LBB2_8:     incl    %eax     incl    %edx     movl    %edx, (%ecx) LBB2_4:     testl    %edx, %edx     jne    LBB2_5     cmpb    $0, (%esi)     jne    LBB2_8     jmp    LBB2_6     .align    16, 0x90 LBB2_5:     cmpl    %edx, %esi     jne    LBB2_8     jmp    LBB2_6     .align    16, 0x90 LBB2_3:     leal    1(%edx,%eax), %esi     incl    %eax     movl    %esi, (%ecx) LBB2_1:     movl    %edx, %esi     addl    %eax, %esi     je    LBB2_6     cmpb    $0, (%esi)     jne    LBB2_3 LBB2_6:     popl    %esi     popl    %ebp     ret <\/code><\/pre>\n<p>  <\/td>\n<td>\n<pre><code>;Iterable-based strlen pushl    %ebp     movl    %esp, %ebp     movl    8(%ebp), %ecx     xorl    %eax, %eax     cmpb    $0, (%ecx)     je    LBB1_4     leal    8(%ebp), %edx     .align    16, 0x90 LBB1_2:     cmpb    $0, 1(%ecx,%eax)     leal    1(%eax), %eax     jne    LBB1_2     addl    %eax, %ecx     movl    %ecx, (%edx) LBB1_4:     popl    %ebp     ret <\/code><\/pre>\n<p>  <\/td>\n<\/tr>\n<\/table>\n<p>  \u041a\u043e\u0434 \u0441 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0440\u0430\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043a\u0440\u0443\u0447\u0435. \u0418 \u043e\u043d \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c <a href=\"http:\/\/habrahabr.ru\/company\/cpp_russia\/blog\/264201\/#rawc\">\u0438\u0437 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u00ab\u0433\u043e\u043b\u043e\u0433\u043e\u00bb \u0421<\/a>.<\/p>\n<h2>\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043f\u0430\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>  \u041d\u043e \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0430 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c?<\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445: <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2012\/n3351.pdf\">N3351<\/a> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u00abx==y\u00bb \u0431\u044b\u043b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0443 \u0445 \u0438 \u0443 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0442\u043e \u044d\u0442\u0438 \u0442\u0438\u043f\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 EqualityComparable, \u0438 \u0443 \u043d\u0438\u0445 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c <i>\u043e\u0431\u0449\u0438\u0439<\/i> \u0442\u0438\u043f, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c, \u0438 \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c EqualityComparable. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c char \u0438 short. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 EqualityComparable, \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 int, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0436\u0435 EqualityComparable.<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0434\u043b\u044f \u043d\u0438\u0445 \u043e\u0431\u0449\u0438\u0439 \u0442\u0438\u043f. \u0412\u043e\u043e\u0431\u0449\u0435, \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a: \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 I, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0442\u0438\u043f-\u0441\u0443\u043c\u043c\u0443, \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438\u0431\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u043b\u0438\u0431\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440. \u041a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442, \u043e\u043d \u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u0438\u0445 \u043e\u0431\u043e\u0438\u0445 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0438\u043f\u0430 I, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0438\u0445 lhs \u0438 rhs, \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u043b\u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435:<\/p>\n<table width=\"639\" cellpadding=\"7\">\n<tbody>\n<tr>\n<td width=\"198\">  lhs \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440?<\/p>\n<\/td>\n<td width=\"199\">  rhs \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440?<\/p>\n<\/td>\n<td width=\"198\">  lhs == rhs?<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"198\">  true<\/p>\n<\/td>\n<td width=\"199\">  true<\/p>\n<\/td>\n<td width=\"198\">  true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"198\">  true<\/p>\n<\/td>\n<td width=\"199\">  false<\/p>\n<\/td>\n<td width=\"198\">  done(rhs.iter)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"198\">  false<\/p>\n<\/td>\n<td width=\"199\">  true<\/p>\n<\/td>\n<td width=\"198\">  done(lhs.iter)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"198\">  false<\/p>\n<\/td>\n<td width=\"199\">  false<\/p>\n<\/td>\n<td width=\"198\">  lhs.iter == rhs.iter<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  \u042d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/company\/cpp_russia\/blog\/264201\/\">\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f c_string_range::iterator<\/a>. \u042d\u0442\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u2013 \u0442\u043e \u0431\u044b\u043b \u043e\u0441\u043e\u0431\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u044d\u0442\u043e\u0439, \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0435\u0439, \u0441\u0445\u0435\u043c\u044b. \u041e\u043d\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0434\u0432\u0430 \u043c\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430, c_string_range \u0438 c_string_iterable. \u041e\u0434\u0438\u043d \u2013 \u043f\u0430\u0440\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043f\u0430\u0440\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\/\u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0438\u0445 \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0445\u043e\u0436\u0438. \u041c\u044b \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 Range \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e Iterable, \u0435\u0441\u043b\u0438 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u043e\u043b\u0438\u043a\u043e\u0439 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u043c\u0443.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432 C++ \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u0443\u0431\u0438\u0440\u0430\u044f \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h2>\u0412\u043e\u0437\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u0418\u0434\u0435\u044f \u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b begin \u0438 end \u043d\u0435 \u043d\u043e\u0432\u0430, \u0438 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0435\u0451 \u043d\u0435 \u044f. \u042f \u0443\u0437\u043d\u0430\u043b \u043e \u043d\u0435\u0439 \u043e\u0442 \u0414\u044d\u0439\u0432\u0430 \u0410\u0431\u0440\u0430\u0445\u0430\u043c\u0441\u0430 (Dave Abrahams) \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0438\u0434\u0435\u044e <a href=\"http:\/\/www.open-std.org\/pipermail\/ranges\/2013-January\/000088.html\">\u043f\u043e\u0434\u0430\u043b<\/a> \u0414\u0438\u0442\u043c\u0430\u0440 \u041a\u044e\u044d\u043b\u044c (Dietmar Kuehl) \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 Ranges, \u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0435\u0433\u043e \u043f\u0438\u0441\u044c\u043c\u043e \u0428\u043e\u043d \u041f\u044d\u0440\u0435\u043d\u0442 (Sean Parent) \u0432\u044b\u0441\u043a\u0430\u0437\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432\u043e\u0437\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<blockquote><p>\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043c\u044b \u0432\u043e\u0437\u043b\u0430\u0433\u0430\u0435\u043c \u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e\u0435. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u2013 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0421\u043c. copy_n() \u0438 copy_sentinel()<\/p>\n<p>  <a href=\"http:\/\/stlab.adobe.com\/copy_8hpp.html\">stlab.adobe.com\/copy_8hpp.html<\/a><\/p>\n<p>  \u041a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u2013 \u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438:<\/p>\n<ol>\n<li>\u043f\u0430\u0440\u044b \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/li>\n<li>\u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e<\/li>\n<li>\u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430<\/li>\n<\/ol>\n<p>  \u0418 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 copy(r, out) \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p><\/blockquote>\n<p>  \u0415\u0441\u043b\u0438 \u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u043f\u043e\u043d\u044f\u043b, \u043e\u043d \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0451\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432: IteratorRange, CountedRange \u0438 SentinelRange. \u0418 \u044d\u0442\u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0440\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e. \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0443\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 50 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u2013 \u0438 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>  \u0425\u0443\u0436\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0443\u0442\u043e\u0447\u043d\u0451\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <a href=\"http:\/\/libcxx.llvm.org\/\">libc++<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c rotate \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0435 \u0432\u044b \u0435\u043c\u0443 \u043f\u0440\u044f\u043c\u044b\u0435, \u0434\u0432\u0443\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0410 \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0451\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 Iterator, Counted \u0438 SentinelRanges \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0431\u044b 9 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 rotate! \u041f\u0440\u0438 \u0432\u0441\u0451\u043c \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0438, \u044d\u0442\u043e \u0431\u0435\u0437\u0443\u043c\u0438\u0435.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430 \u044f \u043f\u0440\u0438\u0432\u0451\u043b \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438 \u0441 \u043f\u0430\u0440\u043d\u044b\u043c\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u042f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e, Iterable, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0438 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432. \u041f\u043e\u043a\u0430 \u044f \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043b, \u043a\u0430\u043a \u044d\u0442\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438, \u043e \u0447\u0451\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u043c, \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435.<\/p>\n<p>  \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/ericniebler\/range-v3\">github<\/a>. <\/p>\n<h2>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u0438<\/h2>\n<p>  \u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0438\u0442\u044c \u042d\u043d\u0434\u0440\u044e \u0421\u0443\u0442\u0442\u043e\u043d\u0430 (Andrew Sutton) \u0437\u0430 \u043f\u043e\u043c\u043e\u043c\u0449\u044c \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c Concpets Lite \u0438 \u0437\u0430 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 EqualityComparable \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043e\u0431\u0449\u0435\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0434\u0435\u0439. \u0421\u0442\u0430\u0442\u044c\u0438 \u0441\u0442\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u0432\u043a\u043b\u0430\u0434\u0443.   \t<\/p>\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\/264975\/\"> http:\/\/habrahabr.ru\/post\/264975\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u0430\u0445 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043e\u043f\u0438\u0448\u0443 \u0432\u0430\u043c \u043c\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u044f \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432:<\/p>\n<ul>\n<li>\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0433\u0435\u043d\u0435\u0440\u044f\u0442 \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u0434<\/li>\n<li>\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u0430\u0431\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u0447\u0435\u043c \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b<\/li>\n<li>\u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0442<\/li>\n<li>\u0438\u0445 \u0442\u0440\u0443\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/li>\n<li>\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438, \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 difference_type<\/li>\n<\/ul>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0440\u0443\u0434\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0451.  <\/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-263765","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263765","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=263765"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263765\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}