{"id":314258,"date":"2020-12-03T15:01:55","date_gmt":"2020-12-03T15:01:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=314258"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=314258","title":{"rendered":"\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u043d\u043e \u0432\u0430\u0436\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p><strong><em>\u0411\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <\/em><\/strong><a href=\"https:\/\/otus.pw\/J4eF\/\"><strong><em>&#171;C++ Developer. Professional&#187;<\/em><\/strong><\/a><strong><em> \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 <\/em><\/strong><a href=\"https:\/\/otus.pw\/faDm\/\"><strong><em>&#171;Backend \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++&#187;.<\/em><\/strong><\/a><strong><em><\/p>\n<p><\/em><\/strong><em>\u0410 \u043f\u043e\u043a\u0430 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/em><\/p>\n<\/blockquote>\n<hr>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 C++20 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>std::map<\/code>, <code>std::set<\/code> \u0438 <code>std::string<\/code>, \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043d\u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0443\u0436\u0435 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u043c\u043d\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u043c\u0438\u0442\u0435\u0442 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0438\u0437\u043d\u0430\u043b \u0438\u0445 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0435\u0440\u0438\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h4>Map \u0438 set<\/h4>\n<p>\u0422\u0438\u043f\u043e\u0432\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>map<\/code> \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 C++17? \u0412\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cpp\">std::map&lt;int, std::string&gt; m{ {1, \"one\"}, {2, \"two\"}, {3, \"three\"} };   if (m.find(1) != m.end()) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u044d\u0442\u043e \u043e\u0442\u043d\u044e\u0434\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0438\u0448\u0443\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>contains()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>map<\/code> \u0438 \u043a\u043b\u044e\u0447 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 <code>map<\/code> \u043a\u043b\u044e\u0447. \u0412 C++20 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0442.\u043a. <code>std::map<\/code> \u0438\u043c\u0435\u0435\u0442 \u0440\u043e\u0434\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>contains()<\/code>.<\/p>\n<pre><code class=\"cpp\">std::map&lt;int, std::string&gt; m{ {1, \"one\"}, {2, \"two\"}, {3, \"three\"} };   if (m.contains(1)) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u0432\u0435\u0440\u043d\u043e \u0438 \u0434\u043b\u044f <code>std::set<\/code><\/p>\n<pre><code class=\"cpp\">std::set&lt;int&gt; s{ 1, 2, 3 }; if (s.contains(1)) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432 C++20 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>contains()<\/code> \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u200b\u200b\u043a \u0446\u0435\u043b\u043e\u043c\u0443 \u0440\u044f\u0434\u0443 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/map\">std::map<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/multimap\">std::multimap<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_map\">std::unordered_map<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_multimap\">std::unordered_multimap<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/set\">std::set<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/multiset\">std::multiset<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_set\">std::unordered_set<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_multiset\">std::unordered_multiset<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u0442\u0440\u043e\u043a\u0438<\/h4>\n<p>\u041f\u043e\u0445\u043e\u0436\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0438 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 C++17:<\/p>\n<pre><code class=\"cpp\">std::string text{\"The quick brown fox jumps over the lazy dog\"};   if (text.find(\"fox\") != std::string::npos) {    std::cout &lt;&lt; \"fox found!\\n\"; }<\/code><\/pre>\n<p>\u0427\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u2014 \u044d\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u043e\u0438\u0441\u043a \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442:<\/p>\n<pre><code class=\"cpp\">if (text.find(\"The quick\") == 0) {    std::cout &lt;&lt; \"right start\\n\"; }<\/code><\/pre>\n<p>\u041d\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u043e\u0432\u0430:<\/p>\n<pre><code class=\"cpp\">bool ends_with(std::string const &amp; text, std::string const &amp; substr) {    if (substr.size() &gt; text.size()) return false;    return std::equal(text.begin() + text.size() - substr.size(), text.end(), substr.begin()); }<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">if (ends_with(text, \"lazy dog\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<p><strong>(\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>:<strong> <\/strong>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/stackoverflow.com\/questions\/874134\/find-out-if-string-ends-with-another-string-in-c\">\u0437\u0434\u0435\u0441\u044c<\/a>)<\/p>\n<p>C++20 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0433\u0434\u0435 <code>std::basic_string<\/code> \u0438 <code>std::basic_string_view  <\/code>\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/string\/basic_string\/starts_with\"><em>starts_with()<\/em><\/a><em> \u0438 <\/em><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/string\/basic_string\/ends_with\"><em>ends_<\/em>with()<\/a><\/p>\n<pre><code class=\"cpp\">if (text.starts_with(\"The quick\")) {    std::cout &lt;&lt; \"right start\\n\"; }   if(text.ends_with(\"lazy dog\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 C++20 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0443\u043f\u0443\u0449\u0435\u043d\u0438\u0435: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u043e\u0433\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443. \u0412\u043e \u0432\u0440\u0435\u043c\u044f <a href=\"https:\/\/herbsutter.com\/2020\/11\/13\/trip-report-autumn-iso-c-standards-meeting-virtual\/\">\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u0430\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0438\u0442\u0435\u0442\u0430 ISO C++<\/a>, \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 C++23 (<a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2020\/p1679r3.html\">P1679<\/a>). \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">if (text.contains(\"fox\")) {    std::cout &lt;&lt; \"fox found!\\n\"; }<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/28c\/d01\/1c3\/28cd011c3d7c83490484e5d8e22ed721\" width=\"443\" height=\"250\"><figcaption><\/figcaption><\/figure>\n<h4>\u041d\u043e\u2026<\/h4>\n<p>\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443. \u041e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u0432\u0430\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>contains()<\/code>, <code>startwith()<\/code><em> \u0438 <\/em><code>endwith()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043f\u043e\u0438\u0441\u043a \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">bool contains_ci(std::string const &amp; text, std::string const &amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.begin(), text.end(),       substr.begin(), substr.end(),       [](char ch1, char ch2) {           return std::toupper(ch1) == std::toupper(ch2); });      return it != text.end(); }   bool starts_with_ci(std::string const&amp; text, std::string const&amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.begin(), text.begin() + substr.length(),       substr.begin(), substr.end(),       [](char ch1, char ch2) {          return std::toupper(ch1) == std::toupper(ch2); });      return it == text.begin(); }   bool ends_with_ci(std::string const&amp; text, std::string const&amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.rbegin(), text.rbegin() + substr.length(),       substr.rbegin(), substr.rend(),       [](char ch1, char ch2) {          return std::toupper(ch1) == std::toupper(ch2); });      return it == text.rbegin(); }<\/code><\/pre>\n<p>\u0410 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">if (contains_ci(text, \"FOX\")) {    std::cout &lt;&lt; \"fox found!\\n\"; }   if (starts_with_ci(text, \"THE QUICK\")) {    std::cout &lt;&lt; \"right start\\n\"; }   if (ends_with_ci(text, \"LAZY DOG\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<hr>\n<blockquote>\n<p><a href=\"https:\/\/otus.pw\/J4eF\/\"><strong>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435<\/strong><\/a><strong> &#171;C++ Developer. Professional&#187;<\/p>\n<p><\/strong><a href=\"https:\/\/otus.pw\/faDm\/\"><strong>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a<\/strong><\/a><strong> &#171;Backend \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++&#187;<\/strong><\/p>\n<\/blockquote>\n<hr>\n<h3>\u0427\u0438\u0442\u0430\u0442\u044c \u0435\u0449\u0451:<\/h3>\n<ul>\n<li>\n<p> <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/520502\/\">\u041f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b C++17<\/a><\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/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=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/531122\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/531122\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p><strong><em>\u0411\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <\/em><\/strong><a href=\"https:\/\/otus.pw\/J4eF\/\"><strong><em>&#171;C++ Developer. Professional&#187;<\/em><\/strong><\/a><strong><em> \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 <\/em><\/strong><a href=\"https:\/\/otus.pw\/faDm\/\"><strong><em>&#171;Backend \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++&#187;.<\/em><\/strong><\/a><strong><em><\/p>\n<p><\/em><\/strong><em>\u0410 \u043f\u043e\u043a\u0430 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/em><\/p>\n<\/blockquote>\n<hr>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 C++20 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>std::map<\/code>, <code>std::set<\/code> \u0438 <code>std::string<\/code>, \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043d\u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0443\u0436\u0435 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u043c\u043d\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u043c\u0438\u0442\u0435\u0442 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0438\u0437\u043d\u0430\u043b \u0438\u0445 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0435\u0440\u0438\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h4>Map \u0438 set<\/h4>\n<p>\u0422\u0438\u043f\u043e\u0432\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>map<\/code> \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 C++17? \u0412\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cpp\">std::map&lt;int, std::string&gt; m{ {1, \"one\"}, {2, \"two\"}, {3, \"three\"} };   if (m.find(1) != m.end()) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u044d\u0442\u043e \u043e\u0442\u043d\u044e\u0434\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0438\u0448\u0443\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>contains()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>map<\/code> \u0438 \u043a\u043b\u044e\u0447 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 <code>map<\/code> \u043a\u043b\u044e\u0447. \u0412 C++20 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0442.\u043a. <code>std::map<\/code> \u0438\u043c\u0435\u0435\u0442 \u0440\u043e\u0434\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>contains()<\/code>.<\/p>\n<pre><code class=\"cpp\">std::map&lt;int, std::string&gt; m{ {1, \"one\"}, {2, \"two\"}, {3, \"three\"} };   if (m.contains(1)) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u0432\u0435\u0440\u043d\u043e \u0438 \u0434\u043b\u044f <code>std::set<\/code><\/p>\n<pre><code class=\"cpp\">std::set&lt;int&gt; s{ 1, 2, 3 }; if (s.contains(1)) {    std::cout &lt;&lt; \"key found!\\n\"; }<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432 C++20 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>contains()<\/code> \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u200b\u200b\u043a \u0446\u0435\u043b\u043e\u043c\u0443 \u0440\u044f\u0434\u0443 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/map\">std::map<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/multimap\">std::multimap<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_map\">std::unordered_map<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_multimap\">std::unordered_multimap<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/set\">std::set<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/multiset\">std::multiset<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_set\">std::unordered_set<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/unordered_multiset\">std::unordered_multiset<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u0442\u0440\u043e\u043a\u0438<\/h4>\n<p>\u041f\u043e\u0445\u043e\u0436\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0438 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 C++17:<\/p>\n<pre><code class=\"cpp\">std::string text{\"The quick brown fox jumps over the lazy dog\"};   if (text.find(\"fox\") != std::string::npos) {    std::cout &lt;&lt; \"fox found!\\n\"; }<\/code><\/pre>\n<p>\u0427\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u2014 \u044d\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u043e\u0438\u0441\u043a \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442:<\/p>\n<pre><code class=\"cpp\">if (text.find(\"The quick\") == 0) {    std::cout &lt;&lt; \"right start\\n\"; }<\/code><\/pre>\n<p>\u041d\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u043e\u0432\u0430:<\/p>\n<pre><code class=\"cpp\">bool ends_with(std::string const &amp; text, std::string const &amp; substr) {    if (substr.size() &gt; text.size()) return false;    return std::equal(text.begin() + text.size() - substr.size(), text.end(), substr.begin()); }<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">if (ends_with(text, \"lazy dog\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<p><strong>(\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>:<strong> <\/strong>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/stackoverflow.com\/questions\/874134\/find-out-if-string-ends-with-another-string-in-c\">\u0437\u0434\u0435\u0441\u044c<\/a>)<\/p>\n<p>C++20 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0433\u0434\u0435 <code>std::basic_string<\/code> \u0438 <code>std::basic_string_view  <\/code>\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/string\/basic_string\/starts_with\"><em>starts_with()<\/em><\/a><em> \u0438 <\/em><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/string\/basic_string\/ends_with\"><em>ends_<\/em>with()<\/a><\/p>\n<pre><code class=\"cpp\">if (text.starts_with(\"The quick\")) {    std::cout &lt;&lt; \"right start\\n\"; }   if(text.ends_with(\"lazy dog\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 C++20 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0443\u043f\u0443\u0449\u0435\u043d\u0438\u0435: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u043e\u0433\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443. \u0412\u043e \u0432\u0440\u0435\u043c\u044f <a href=\"https:\/\/herbsutter.com\/2020\/11\/13\/trip-report-autumn-iso-c-standards-meeting-virtual\/\">\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u0430\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0438\u0442\u0435\u0442\u0430 ISO C++<\/a>, \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 C++23 (<a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2020\/p1679r3.html\">P1679<\/a>). \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">if (text.contains(\"fox\")) {    std::cout &lt;&lt; \"fox found!\\n\"; }<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<h4>\u041d\u043e\u2026<\/h4>\n<p>\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443. \u041e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u0432\u0430\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>contains()<\/code>, <code>startwith()<\/code><em> \u0438 <\/em><code>endwith()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043f\u043e\u0438\u0441\u043a \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">bool contains_ci(std::string const &amp; text, std::string const &amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.begin(), text.end(),       substr.begin(), substr.end(),       [](char ch1, char ch2) {           return std::toupper(ch1) == std::toupper(ch2); });      return it != text.end(); }   bool starts_with_ci(std::string const&amp; text, std::string const&amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.begin(), text.begin() + substr.length(),       substr.begin(), substr.end(),       [](char ch1, char ch2) {          return std::toupper(ch1) == std::toupper(ch2); });      return it == text.begin(); }   bool ends_with_ci(std::string const&amp; text, std::string const&amp; substr) {    if (substr.length() &gt; text.length()) return false;      auto it = std::search(       text.rbegin(), text.rbegin() + substr.length(),       substr.rbegin(), substr.rend(),       [](char ch1, char ch2) {          return std::toupper(ch1) == std::toupper(ch2); });      return it == text.rbegin(); }<\/code><\/pre>\n<p>\u0410 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">if (contains_ci(text, \"FOX\")) {    std::cout &lt;&lt; \"fox found!\\n\"; }   if (starts_with_ci(text, \"THE QUICK\")) {    std::cout &lt;&lt; \"right start\\n\"; }   if (ends_with_ci(text, \"LAZY DOG\")) {    std::cout &lt;&lt; \"right end\\n\"; }<\/code><\/pre>\n<hr>\n<blockquote>\n<p><a href=\"https:\/\/otus.pw\/J4eF\/\"><strong>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435<\/strong><\/a><strong> &#171;C++ Developer. Professional&#187;<\/p>\n<p><\/strong><a href=\"https:\/\/otus.pw\/faDm\/\"><strong>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a<\/strong><\/a><strong> &#171;Backend \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0421++&#187;<\/strong><\/p>\n<\/blockquote>\n<hr>\n<h3>\u0427\u0438\u0442\u0430\u0442\u044c \u0435\u0449\u0451:<\/h3>\n<ul>\n<li>\n<p> <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/520502\/\">\u041f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b C++17<\/a><\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/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=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/531122\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/531122\/<\/a><br \/><\/br><\/br><\/p>\n<\/blockquote>\n<\/hr>\n<\/hr>\n<\/blockquote>\n<\/div>\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-314258","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314258","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=314258"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314258\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}