{"id":473211,"date":"2025-09-02T15:49:06","date_gmt":"2025-09-02T15:49:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=473211"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=473211","title":{"rendered":"<span>\u0412\u0441\u0451 \u043f\u0440\u043e std::search \u0438 \u0433\u0434\u0435 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0435\u0437\u00a0\u043f\u0440\u0435\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0439 \u043e\u0434\u0438\u043d \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0\u2014 <code>std::search<\/code>. \u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d, \u0433\u0434\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0435 \u0442\u0438\u043a\u0438, \u0430\u00a0\u0433\u0434\u0435 \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u00a0\u0447\u0442\u043e\u2011\u0442\u043e \u0438\u043d\u043e\u0435. <\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 std::search<\/h3>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0449\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>[s_first, s_last)<\/code> \u0432\u00a0\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 <code>[first, last)<\/code>. \u0415\u0441\u043b\u0438 \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u043f\u0443\u0441\u0442\u0430\u044f, \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f <code>first<\/code>, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u0442\u00a0\u2014 <code>last<\/code>. \u0412\u00a0\u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>operator==<\/code>; \u043f\u0440\u0438\u00a0\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0438\u043b\u0438\u00a0\u0446\u0435\u043b\u044b\u0439 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a. \u0421\u00a0C++20\u00a0\u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 <code>search<\/code> \u0441\u0442\u0430\u043b\u0438 <code>constexpr<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e\u00a0\u0442\u0435\u043f\u0435\u0440\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u0430\u0436\u0435 \u0432 <code>static_assert<\/code>\u2011\u0430\u0445.<\/p>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u00a0\u043b\u043e\u0431\u043e\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u00a0\u0440\u0430\u0434\u0443\u0435\u0442: \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c <code>N \u00d7 S<\/code> \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 <code>N = distance(first, last)<\/code>, <code>S = distance(s_first, s_last)<\/code>\u00a0\u2014 \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0432\u00a0\u043a\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u0430\u00a0\u0433\u0434\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u044b\u0435 searcher\u2011\u044b \u0438\u043b\u0438\u00a0\u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(f1,l1, f2,l2)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0447\u0435\u0440\u0435\u0437 <code>==<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">constexpr \u0441\u00a0C++20<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(f1,l1, f2,l2, pred)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u00a0\u0436\u0435, \u043d\u043e\u00a0\u0441\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0441\u043a\u0438\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u043b\u044f\u00a0\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(par,...)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435\/\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043b\u0435\u0434\u0443\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b\u043c \u0441\u00a0\u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(first,last, searcher)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443\u2011\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Boyer\u2011Moore \u0438 BMH<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430\u00a0\u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430 \u043f\u0440\u0438\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445. \u0412\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0442\u0440\u0438 searcher\u2011\u0430: <code>default_searcher<\/code> (\u043d\u0430\u0438\u0432\u043d\u044b\u0439), <code>boyer_moore_searcher<\/code> \u0438 <code>boyer_moore_horspool_searcher<\/code>. \u041e\u043d\u0438 \u0436\u0438\u0432\u0443\u0442 \u0432 <code>&lt;functional&gt;<\/code> \u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 C++17. \u041d\u0430\u00a0\u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0432\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u00a0\u2014 \u043d\u043e\u0440\u043c\u0430. <\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438<\/h3>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;string_view&gt; #include &lt;iostream&gt;  bool contains(std::string_view haystack, std::string_view needle) {     return std::search(haystack.begin(), haystack.end(),                        needle.begin(),  needle.end()) != haystack.end(); }  int main() {     std::string_view text  = \"\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442 STL\";     std::cout &lt;&lt; std::boolalpha               &lt;&lt; contains(text, \"STL\")    \/\/ true               &lt;&lt; '\\n'               &lt;&lt; contains(text, \"Rust\");  \/\/ false }<\/code><\/pre>\n<p>\u041a\u043e\u0434\u0430 \u043f\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043d\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u043f\u0443\u0441\u0442\u0430, \u0432\u0435\u0440\u043d\u0451\u043c begin, \u0447\u0442\u043e\u00a0\u0438\u043d\u043e\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f\u00a0\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442: \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h3>\n<p>\u0427\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\"http\"<\/code> \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 <code>std::search<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442:  <\/p>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;cctype&gt; #include &lt;string&gt;  auto ci_equal = [](char a, char b) {     return std::tolower(static_cast&lt;unsigned char&gt;(a)) ==            std::tolower(static_cast&lt;unsigned char&gt;(b)); };  bool ci_contains(const std::string&amp; haystack, const std::string&amp; needle) {     return std::search(haystack.begin(), haystack.end(),                        needle.begin(),  needle.end(),                        ci_equal) != haystack.end(); }<\/code><\/pre>\n<p><code>std::search<\/code> \u0438\u0449\u0435\u0442 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<p><code>std::tolower<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>unsigned char<\/code>, \u0438\u043d\u0430\u0447\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d UB \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 &gt;127 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u043e\u043a\u0430\u043b\u044f\u0445.<\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u043a\u043e\u0433\u0434\u0430 \u0431\u0440\u0430\u0442\u044c boyer_moore_searcher<\/h3>\n<p>\u041d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u0445\u043e\u0434\u0430\u0445 (<code>N &gt; 1 000<\/code> \u0438 <code>S &gt; 3<\/code>) \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0442\u0443\u0445\u043d\u0443\u0442\u044c. Boyer\u2011Moore \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439. \u0412\u00a0\u043c\u043e\u0438\u0445 \u0437\u0430\u043c\u0435\u0440\u0430\u0445 \u043d\u0430\u00a0\u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043b\u043e\u0433\u0435 5\u00a0\u041c\u0411 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e ~6\u00d7 \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0\u0431\u0430\u0437\u043e\u0432\u044b\u043c <code>search<\/code>. \u041f\u0440\u043e\u0444\u0438\u043b\u044c\u00a0\u0431\u044b\u043b \u0447\u0438\u0441\u0442\u044b\u0439: \u0432\u0441\u0451 \u0443\u043f\u0438\u0440\u0430\u043b\u043e\u0441\u044c \u0432 <code>memcmp<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u0441\u043a\u0430\u0434\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;functional&gt; #include &lt;string_view&gt;  std::size_t bm_find(std::string_view haystack, std::string_view needle) {     using searcher = std::boyer_moore_searcher&lt;         std::string_view::iterator, std::string_view::iterator&gt;;      auto it = std::search(haystack.begin(), haystack.end(),                           searcher(needle.begin(), needle.end()));     return it == haystack.end() ? std::string_view::npos                                 : std::distance(haystack.begin(), it); }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c searcher \u043b\u0443\u0447\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h3>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>\u0421\u00a0C++17\u00a0\u043a\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>search<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 <code>ExecutionPolicy<\/code>. \u041d\u0430\u00a0\u0434\u0435\u0441\u043a\u0442\u043e\u043f\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0444\u0438\u0442, \u0435\u0441\u043b\u0438:<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u00a0\u0432\u0430\u0441 \u043d\u0435\u00a0\u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0430, \u0441\u043a\u0430\u0436\u0435\u043c, <code>std::vector&lt;int&gt;<\/code> \u0441\u00a0\u0442\u044f\u0436\u0451\u043b\u044b\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a\u00a0\u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0443 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;execution&gt; #include &lt;vector&gt;  auto it = std::search(std::execution::par_unseq,                       data.begin(), data.end(),                       pattern.begin(), pattern.end());<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043d\u0435\u00a0\u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d \u043e\u0442\u00a0\u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u00a0\u2014 \u0437\u0430\u043f\u0440\u0435\u0442\u043d\u0430\u044f \u0437\u043e\u043d\u0430. \u0412\u00a0\u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0433\u043e\u043d\u043a\u0438 \u0438 \u0432\u0435\u0441\u0451\u043b\u044b\u0439 undefined behaviour. <\/p>\n<h3>ranges::search<\/h3>\n<p>\u0421\u00a0C++20\u00a0\u043a\u00a0\u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0438 ranges. \u0424\u0443\u043d\u043a\u0446\u0438\u044f\u2011\u043e\u0431\u044a\u0435\u043a\u0442 <code>std::ranges::search<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>std::ranges::subrange<\/code>, \u0447\u0442\u043e\u00a0\u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u00a0\u0433\u0438\u043c\u043d\u0430\u0441\u0442\u0438\u043a\u0438 \u0441 <code>distance<\/code>:<\/p>\n<pre><code class=\"cpp\">#include &lt;ranges&gt; #include &lt;string_view&gt;  auto sub = std::ranges::search(haystack, needle); if (!sub.empty()) {     \/\/ sub.begin() \u0434\u0430\u0451\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e }<\/code><\/pre>\n<p>ranges\u2011\u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0438\u043f\u0430 <code>boyer_moore_searcher<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438,\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0451\u043c\u0441\u044f \u043d\u0430\u00a0\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c API. <\/p>\n<h3>\u041a\u0435\u0439\u0441 1: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e\u0432\u0435\u0440\u0445 TCP, \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u044f\u043a \u043f\u0430\u043a\u0435\u0442\u0430 \u0432\u0440\u043e\u0434\u0435 <code>0xDE,0xAD,0xBE,0xEF<\/code>. \u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0435\u043d:<\/p>\n<pre><code class=\"cpp\">bool has_magic(const std::vector&lt;std::uint8_t&gt;&amp; buf) {     constexpr std::uint8_t magic[] {0xDE, 0xAD, 0xBE, 0xEF};     auto it = std::search(buf.begin(), buf.end(),                           std::begin(magic), std::end(magic));     return it != buf.end(); }<\/code><\/pre>\n<p>\u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0439 \u043f\u043e\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044e \u043d\u0435\u00a0\u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0430\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0434\u0451\u0442 \u0431\u0430\u0439\u0442 \u043a\u00a0\u0431\u0430\u0439\u0442\u0443.<\/p>\n<h3>\u041a\u0435\u0439\u0441 2: \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0430 mmap-\u043e\u043c<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043b\u043e\u0433 \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043f\u0430\u043c\u044f\u0442\u044c \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043c \u0437\u0430\u00a0\u0441\u0447\u0451\u0442 <code>mmap<\/code>. \u0418\u0449\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u00abERROR\u00bb:<\/p>\n<pre><code class=\"cpp\">#include &lt;fcntl.h&gt; #include &lt;sys\/mman.h&gt; #include &lt;algorithm&gt; #include &lt;string_view&gt;  void scan_log(const char* path) {     int fd = open(path, O_RDONLY);     off_t size = lseek(fd, 0, SEEK_END);     char* map = static_cast&lt;char*&gt;(mmap(nullptr, size, PROT_READ,                                         MAP_PRIVATE, fd, 0));     std::string_view log{map, static_cast&lt;std::size_t&gt;(size)};     auto it = std::search(log.begin(), log.end(),                           \"ERROR\", \"ERROR\" + 5);     if (it != log.end()) {         \/\/ \u043d\u0430\u0448\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0440\u0435\u043f\u043e\u0440\u0442\u0438\u043c     }     munmap(map, size);     close(fd); }<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0432\u0432\u043e\u0434\u2011\u0432\u044b\u0432\u043e\u0434 \u043c\u044b \u0441\u0432\u0435\u043b\u0438 \u043a\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c, \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435\u00a0\u2014 \u0447\u0438\u0441\u0442\u044b\u0439 <code>std::search<\/code>.<\/p>\n<h3>\u041a\u0435\u0439\u0441 3: \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432<\/h3>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u00a0\u0437\u0430\u043f\u0440\u0435\u0449\u0451\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438. \u0421\u00a0\u043a\u043e\u0434 \u0442\u0438\u043f\u0430 <code>strcasestr<\/code> \u0434\u0430\u0432\u043d\u043e \u043d\u0435\u00a0\u043a\u0430\u0442\u0438\u0442; \u043f\u0438\u0448\u0435\u043c \u043d\u0430\u00a0C++:<\/p>\n<pre><code class=\"cpp\">#include &lt;string_view&gt; #include &lt;algorithm&gt;  bool contains_header(std::string_view request,                      std::string_view header) {     auto pred = [](char a, char b)     {         return std::tolower(static_cast&lt;unsigned char&gt;(a)) ==                std::tolower(static_cast&lt;unsigned char&gt;(b));     };      return std::search(request.begin(), request.end(),                        header.begin(), header.end(),                        pred) != request.end(); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u00a0\u0430\u043b\u043b\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435\u00a0\u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430 \u0434\u043b\u044f\u00a0\u0441\u0430\u043d\u0438\u0442\u0430\u0439\u0437\u0435\u0440\u043e\u0432.<\/p>\n<h3>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, c \u0447\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f: \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u00a0\u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d. \u0414\u043b\u044f\u00a0\u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u0432\u044b\u0433\u043e\u0434\u043d\u0435\u0435 \u0441\u0440\u0430\u0437\u0443 \u0431\u0440\u0430\u0442\u044c <code>std::find<\/code>, \u0430\u00a0\u043d\u0435\u00a0\u0442\u044f\u043d\u0443\u0442\u044c \u043d\u0430\u00a0\u0441\u0446\u0435\u043d\u0443 \u0432\u0435\u0441\u044c <code>search<\/code>. \u041f\u043b\u044e\u0441 \u043d\u0435\u00a0\u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e\u00a0\u043f\u0443\u0441\u0442\u0430\u044f \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>first<\/code>; \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u00a0\u0436\u0434\u0443\u0442, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432\u00a0\u043a\u0432\u0435\u0441\u0442.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. <code>std::search<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u00a0\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f\u00a0UTF-8\u00a0\u043d\u0443\u0436\u0435\u043d \u0441\u043b\u043e\u0439 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438\u00a0\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u041d\u0430\u00a0\u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 Boyer\u2011Moore \u0442\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u2011\u0437\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\u00a0\u2014 \u043f\u043e\u0440\u043e\u0433 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u043c. \u0418 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u00a0\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u043c \u043e\u0442\u00a0I\/O, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0438 \u0440\u0438\u0441\u043a\u0443\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a\u00a0\u0433\u043e\u043d\u043a\u0430\u043c; \u0432\u00a0\u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u043e\u0441\u0442\u0430\u0451\u043c\u0441\u044f \u043d\u0430\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p><code>std::search<\/code>\u00a0\u2014 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043f\u043e\u00a0mmap\u2011\u0444\u0430\u0439\u043b\u0430\u043c \u0431\u0435\u0437\u00a0\u043a\u043e\u043f\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0441\u00a0\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e\u0434\u00a0\u0437\u0430\u0434\u0430\u0447\u0443: \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043b\u044f\u00a0\u043c\u0435\u043b\u043e\u0447\u0438, Boyer\u2011Moore \u0434\u043b\u044f\u00a0\u0442\u044f\u0436\u0451\u043b\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, <code>par_unseq<\/code> \u0434\u043b\u044f\u00a0\u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, <code>ranges::search<\/code> \u0434\u043b\u044f\u00a0\u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. <\/p>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441\u00a0C++ \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0430\u0441 \u043f\u0440\u043e\u0439\u0442\u0438 <a href=\"https:\/\/otus.pw\/eh2D\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0432\u0430\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a\u00a0\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0443\u0440\u043e\u043a\u0430\u043c:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/otus.pw\/nHhn8\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u00a0C++<\/a>\u00a0\u2014 <em>6\u00a0\u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 20:00<\/em>. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u00a0\u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0C++.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/otus.pw\/dNCK\/\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b C++<\/a>\u00a0\u2014 <em>20\u00a0\u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 20:00<\/em>. \u0423\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b \u0434\u043b\u044f\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u043a\u0430\u043a\u00a0\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u00a0\u043a\u0443\u0440\u0441\u0430\u0445 \u043f\u043e <em>C++<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u00a0\u0437\u0430\u043f\u0438\u0441\u044f\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0443\u0440\u043e\u043a\u043e\u0432, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/t.me\/otus_cplus_bot?start=habr\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u2011\u0431\u043e\u0442<\/a>.<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/932988\/\"> https:\/\/habr.com\/ru\/articles\/932988\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0435\u0437\u00a0\u043f\u0440\u0435\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0439 \u043e\u0434\u0438\u043d \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0\u2014 <code>std::search<\/code>. \u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d, \u0433\u0434\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0435 \u0442\u0438\u043a\u0438, \u0430\u00a0\u0433\u0434\u0435 \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u00a0\u0447\u0442\u043e\u2011\u0442\u043e \u0438\u043d\u043e\u0435. <\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 std::search<\/h3>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0449\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>[s_first, s_last)<\/code> \u0432\u00a0\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 <code>[first, last)<\/code>. \u0415\u0441\u043b\u0438 \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u043f\u0443\u0441\u0442\u0430\u044f, \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f <code>first<\/code>, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u0442\u00a0\u2014 <code>last<\/code>. \u0412\u00a0\u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>operator==<\/code>; \u043f\u0440\u0438\u00a0\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0438\u043b\u0438\u00a0\u0446\u0435\u043b\u044b\u0439 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a. \u0421\u00a0C++20\u00a0\u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 <code>search<\/code> \u0441\u0442\u0430\u043b\u0438 <code>constexpr<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e\u00a0\u0442\u0435\u043f\u0435\u0440\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u0430\u0436\u0435 \u0432 <code>static_assert<\/code>\u2011\u0430\u0445.<\/p>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u00a0\u043b\u043e\u0431\u043e\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u00a0\u0440\u0430\u0434\u0443\u0435\u0442: \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c <code>N \u00d7 S<\/code> \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 <code>N = distance(first, last)<\/code>, <code>S = distance(s_first, s_last)<\/code>\u00a0\u2014 \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0432\u00a0\u043a\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u0430\u00a0\u0433\u0434\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u044b\u0435 searcher\u2011\u044b \u0438\u043b\u0438\u00a0\u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(f1,l1, f2,l2)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0447\u0435\u0440\u0435\u0437 <code>==<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">constexpr \u0441\u00a0C++20<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(f1,l1, f2,l2, pred)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u00a0\u0436\u0435, \u043d\u043e\u00a0\u0441\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0441\u043a\u0438\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u043b\u044f\u00a0\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(par,...)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435\/\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043b\u0435\u0434\u0443\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b\u043c \u0441\u00a0\u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>search(first,last, searcher)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443\u2011\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a\u0443<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Boyer\u2011Moore \u0438 BMH<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430\u00a0\u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430 \u043f\u0440\u0438\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445. \u0412\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0442\u0440\u0438 searcher\u2011\u0430: <code>default_searcher<\/code> (\u043d\u0430\u0438\u0432\u043d\u044b\u0439), <code>boyer_moore_searcher<\/code> \u0438 <code>boyer_moore_horspool_searcher<\/code>. \u041e\u043d\u0438 \u0436\u0438\u0432\u0443\u0442 \u0432 <code>&lt;functional&gt;<\/code> \u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 C++17. \u041d\u0430\u00a0\u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0432\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u00a0\u2014 \u043d\u043e\u0440\u043c\u0430. <\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438<\/h3>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;string_view&gt; #include &lt;iostream&gt;  bool contains(std::string_view haystack, std::string_view needle) {     return std::search(haystack.begin(), haystack.end(),                        needle.begin(),  needle.end()) != haystack.end(); }  int main() {     std::string_view text  = \"\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442 STL\";     std::cout &lt;&lt; std::boolalpha               &lt;&lt; contains(text, \"STL\")    \/\/ true               &lt;&lt; '\\n'               &lt;&lt; contains(text, \"Rust\");  \/\/ false }<\/code><\/pre>\n<p>\u041a\u043e\u0434\u0430 \u043f\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043d\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u043f\u0443\u0441\u0442\u0430, \u0432\u0435\u0440\u043d\u0451\u043c begin, \u0447\u0442\u043e\u00a0\u0438\u043d\u043e\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f\u00a0\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442: \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h3>\n<p>\u0427\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\"http\"<\/code> \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 <code>std::search<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442:  <\/p>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;cctype&gt; #include &lt;string&gt;  auto ci_equal = [](char a, char b) {     return std::tolower(static_cast&lt;unsigned char&gt;(a)) ==            std::tolower(static_cast&lt;unsigned char&gt;(b)); };  bool ci_contains(const std::string&amp; haystack, const std::string&amp; needle) {     return std::search(haystack.begin(), haystack.end(),                        needle.begin(),  needle.end(),                        ci_equal) != haystack.end(); }<\/code><\/pre>\n<p><code>std::search<\/code> \u0438\u0449\u0435\u0442 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<p><code>std::tolower<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>unsigned char<\/code>, \u0438\u043d\u0430\u0447\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d UB \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 &gt;127 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u043e\u043a\u0430\u043b\u044f\u0445.<\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u043a\u043e\u0433\u0434\u0430 \u0431\u0440\u0430\u0442\u044c boyer_moore_searcher<\/h3>\n<p>\u041d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u0445\u043e\u0434\u0430\u0445 (<code>N &gt; 1 000<\/code> \u0438 <code>S &gt; 3<\/code>) \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0442\u0443\u0445\u043d\u0443\u0442\u044c. Boyer\u2011Moore \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439. \u0412\u00a0\u043c\u043e\u0438\u0445 \u0437\u0430\u043c\u0435\u0440\u0430\u0445 \u043d\u0430\u00a0\u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043b\u043e\u0433\u0435 5\u00a0\u041c\u0411 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e ~6\u00d7 \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0\u0431\u0430\u0437\u043e\u0432\u044b\u043c <code>search<\/code>. \u041f\u0440\u043e\u0444\u0438\u043b\u044c\u00a0\u0431\u044b\u043b \u0447\u0438\u0441\u0442\u044b\u0439: \u0432\u0441\u0451 \u0443\u043f\u0438\u0440\u0430\u043b\u043e\u0441\u044c \u0432 <code>memcmp<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u0441\u043a\u0430\u0434\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;functional&gt; #include &lt;string_view&gt;  std::size_t bm_find(std::string_view haystack, std::string_view needle) {     using searcher = std::boyer_moore_searcher&lt;         std::string_view::iterator, std::string_view::iterator&gt;;      auto it = std::search(haystack.begin(), haystack.end(),                           searcher(needle.begin(), needle.end()));     return it == haystack.end() ? std::string_view::npos                                 : std::distance(haystack.begin(), it); }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c searcher \u043b\u0443\u0447\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h3>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>\u0421\u00a0C++17\u00a0\u043a\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>search<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 <code>ExecutionPolicy<\/code>. \u041d\u0430\u00a0\u0434\u0435\u0441\u043a\u0442\u043e\u043f\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0444\u0438\u0442, \u0435\u0441\u043b\u0438:<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u00a0\u0432\u0430\u0441 \u043d\u0435\u00a0\u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0430, \u0441\u043a\u0430\u0436\u0435\u043c, <code>std::vector&lt;int&gt;<\/code> \u0441\u00a0\u0442\u044f\u0436\u0451\u043b\u044b\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a\u00a0\u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0443 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#include &lt;algorithm&gt; #include &lt;execution&gt; #include &lt;vector&gt;  auto it = std::search(std::execution::par_unseq,                       data.begin(), data.end(),                       pattern.begin(), pattern.end());<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043d\u0435\u00a0\u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d \u043e\u0442\u00a0\u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u00a0\u2014 \u0437\u0430\u043f\u0440\u0435\u0442\u043d\u0430\u044f \u0437\u043e\u043d\u0430. \u0412\u00a0\u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0433\u043e\u043d\u043a\u0438 \u0438 \u0432\u0435\u0441\u0451\u043b\u044b\u0439 undefined behaviour. <\/p>\n<h3>ranges::search<\/h3>\n<p>\u0421\u00a0C++20\u00a0\u043a\u00a0\u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0438 ranges. \u0424\u0443\u043d\u043a\u0446\u0438\u044f\u2011\u043e\u0431\u044a\u0435\u043a\u0442 <code>std::ranges::search<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>std::ranges::subrange<\/code>, \u0447\u0442\u043e\u00a0\u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u00a0\u0433\u0438\u043c\u043d\u0430\u0441\u0442\u0438\u043a\u0438 \u0441 <code>distance<\/code>:<\/p>\n<pre><code class=\"cpp\">#include &lt;ranges&gt; #include &lt;string_view&gt;  auto sub = std::ranges::search(haystack, needle); if (!sub.empty()) {     \/\/ sub.begin() \u0434\u0430\u0451\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e }<\/code><\/pre>\n<p>ranges\u2011\u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0438\u043f\u0430 <code>boyer_moore_searcher<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438,\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0451\u043c\u0441\u044f \u043d\u0430\u00a0\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c API. <\/p>\n<h3>\u041a\u0435\u0439\u0441 1: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e\u0432\u0435\u0440\u0445 TCP, \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u044f\u043a \u043f\u0430\u043a\u0435\u0442\u0430 \u0432\u0440\u043e\u0434\u0435 <code>0xDE,0xAD,0xBE,0xEF<\/code>. \u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0435\u043d:<\/p>\n<pre><code class=\"cpp\">bool has_magic(const std::vector&lt;std::uint8_t&gt;&amp; buf) {     constexpr std::uint8_t magic[] {0xDE, 0xAD, 0xBE, 0xEF};     auto it = std::search(buf.begin(), buf.end(),                           std::begin(magic), std::end(magic));     return it != buf.end(); }<\/code><\/pre>\n<p>\u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0439 \u043f\u043e\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044e \u043d\u0435\u00a0\u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0430\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0434\u0451\u0442 \u0431\u0430\u0439\u0442 \u043a\u00a0\u0431\u0430\u0439\u0442\u0443.<\/p>\n<h3>\u041a\u0435\u0439\u0441 2: \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0430 mmap-\u043e\u043c<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043b\u043e\u0433 \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043f\u0430\u043c\u044f\u0442\u044c \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043c \u0437\u0430\u00a0\u0441\u0447\u0451\u0442 <code>mmap<\/code>. \u0418\u0449\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u00abERROR\u00bb:<\/p>\n<pre><code class=\"cpp\">#include &lt;fcntl.h&gt; #include &lt;sys\/mman.h&gt; #include &lt;algorithm&gt; #include &lt;string_view&gt;  void scan_log(const char* path) {     int fd = open(path, O_RDONLY);     off_t size = lseek(fd, 0, SEEK_END);     char* map = static_cast&lt;char*&gt;(mmap(nullptr, size, PROT_READ,                                         MAP_PRIVATE, fd, 0));     std::string_view log{map, static_cast&lt;std::size_t&gt;(size)};     auto it = std::search(log.begin(), log.end(),                           \"ERROR\", \"ERROR\" + 5);     if (it != log.end()) {         \/\/ \u043d\u0430\u0448\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0440\u0435\u043f\u043e\u0440\u0442\u0438\u043c     }     munmap(map, size);     close(fd); }<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0432\u0432\u043e\u0434\u2011\u0432\u044b\u0432\u043e\u0434 \u043c\u044b \u0441\u0432\u0435\u043b\u0438 \u043a\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c, \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435\u00a0\u2014 \u0447\u0438\u0441\u0442\u044b\u0439 <code>std::search<\/code>.<\/p>\n<h3>\u041a\u0435\u0439\u0441 3: \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432<\/h3>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u00a0\u0437\u0430\u043f\u0440\u0435\u0449\u0451\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438. \u0421\u00a0\u043a\u043e\u0434 \u0442\u0438\u043f\u0430 <code>strcasestr<\/code> \u0434\u0430\u0432\u043d\u043e \u043d\u0435\u00a0\u043a\u0430\u0442\u0438\u0442; \u043f\u0438\u0448\u0435\u043c \u043d\u0430\u00a0C++:<\/p>\n<pre><code class=\"cpp\">#include &lt;string_view&gt; #include &lt;algorithm&gt;  bool contains_header(std::string_view request,                      std::string_view header) {     auto pred = [](char a, char b)     {         return std::tolower(static_cast&lt;unsigned char&gt;(a)) ==                std::tolower(static_cast&lt;unsigned char&gt;(b));     };      return std::search(request.begin(), request.end(),                        header.begin(), header.end(),                        pred) != request.end(); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u00a0\u0430\u043b\u043b\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435\u00a0\u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430 \u0434\u043b\u044f\u00a0\u0441\u0430\u043d\u0438\u0442\u0430\u0439\u0437\u0435\u0440\u043e\u0432.<\/p>\n<h3>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, c \u0447\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f: \u00ab\u0438\u0433\u043e\u043b\u043a\u0430\u00bb \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u00a0\u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d. \u0414\u043b\u044f\u00a0\u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u0432\u044b\u0433\u043e\u0434\u043d\u0435\u0435 \u0441\u0440\u0430\u0437\u0443 \u0431\u0440\u0430\u0442\u044c <code>std::find<\/code>, \u0430\u00a0\u043d\u0435\u00a0\u0442\u044f\u043d\u0443\u0442\u044c \u043d\u0430\u00a0\u0441\u0446\u0435\u043d\u0443 \u0432\u0435\u0441\u044c <code>search<\/code>. \u041f\u043b\u044e\u0441 \u043d\u0435\u00a0\u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e\u00a0\u043f\u0443\u0441\u0442\u0430\u044f \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>first<\/code>; \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u00a0\u0436\u0434\u0443\u0442, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432\u00a0\u043a\u0432\u0435\u0441\u0442.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. <code>std::search<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u00a0\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f\u00a0UTF-8\u00a0\u043d\u0443\u0436\u0435\u043d \u0441\u043b\u043e\u0439 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438\u00a0\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u041d\u0430\u00a0\u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 Boyer\u2011Moore \u0442\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u2011\u0437\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\u00a0\u2014 \u043f\u043e\u0440\u043e\u0433 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u043c. \u0418 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u00a0\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u043c \u043e\u0442\u00a0I\/O, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0438 \u0440\u0438\u0441\u043a\u0443\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a\u00a0\u0433\u043e\u043d\u043a\u0430\u043c; \u0432\u00a0\u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u043e\u0441\u0442\u0430\u0451\u043c\u0441\u044f \u043d\u0430\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p><code>std::search<\/code>\u00a0\u2014 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043f\u043e\u00a0mmap\u2011\u0444\u0430\u0439\u043b\u0430\u043c \u0431\u0435\u0437\u00a0\u043a\u043e\u043f\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0441\u00a0\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e\u0434\u00a0\u0437\u0430\u0434\u0430\u0447\u0443: \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043b\u044f\u00a0\u043c\u0435\u043b\u043e\u0447\u0438, Boyer\u2011Moore \u0434\u043b\u044f\u00a0\u0442\u044f\u0436\u0451\u043b\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, <code>par_unseq<\/code> \u0434\u043b\u044f\u00a0\u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, <code>ranges::search<\/code> \u0434\u043b\u044f\u00a0\u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. <\/p>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441\u00a0C++ \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0430\u0441 \u043f\u0440\u043e\u0439\u0442\u0438 <a href=\"https:\/\/otus.pw\/eh2D\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0432\u0430\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a\u00a0\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0443\u0440\u043e\u043a\u0430\u043c:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/otus.pw\/nHhn8\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u00a0C++<\/a>\u00a0\u2014 <em>6\u00a0\u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 20:00<\/em>. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u00a0\u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0C++.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/otus.pw\/dNCK\/\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b C++<\/a>\u00a0\u2014 <em>20\u00a0\u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 20:00<\/em>. \u0423\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b \u0434\u043b\u044f\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u043a\u0430\u043a\u00a0\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u00a0\u043a\u0443\u0440\u0441\u0430\u0445 \u043f\u043e <em>C++<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u00a0\u0437\u0430\u043f\u0438\u0441\u044f\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0443\u0440\u043e\u043a\u043e\u0432, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/t.me\/otus_cplus_bot?start=habr\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u2011\u0431\u043e\u0442<\/a>.<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/932988\/\"> https:\/\/habr.com\/ru\/articles\/932988\/<\/a><br \/><\/br><\/br><\/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-473211","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473211","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=473211"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473211\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}