{"id":287528,"date":"2018-08-16T14:11:16","date_gmt":"2018-08-16T10:11:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=287528"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=287528","title":{"rendered":"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 in \u0432 \u0421++"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419579\/\" class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438. \u041c\u043e\u0438\u043c \u0445\u043e\u0431\u0431\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u044f\u043a\u0438\u0445 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0448\u0442\u0443\u043a \u043d\u0430 \u0421++, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043c\u043d\u0435 \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0435\u0439 \u044f\u0437\u044b\u043a\u0430 \u043d\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u0432\u043b\u0435\u0447\u044c\u0441\u044f. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 in \u0435\u0441\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Python, JS. \u041d\u043e \u0432 \u0421++ \u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0432\u0435\u0437\u043b\u0438, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0435\u0433\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cpp\">\tstd::unordered_map&lt;std::string, std::string&gt; some_map =  \t{ \t\t{ \"black\", \"white\" }, \t\t{ \"cat\", \"dog\" }, \t\t{ \"day\", \"night\" } \t};  \tif (auto res = \"cat\" in some_map) \t{ \t\tres-&gt;second = \"fish\"; \t} <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u044f \u043f\u043e\u043b\u0430\u0433\u0430\u044e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u041e\u043d \u0431\u0435\u0440\u0451\u0442 \u043b\u0435\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0435\u0441\u0442\u044c \u043b\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u0440\u0430\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439. \u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u0442, \u043a\u0430\u043a \u043d\u0435\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0438 \u0431\u044b\u043b\u0430 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u0445. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 in \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"cpp\">bool operator_in(const string&amp; key, const unordered_map&lt;string, string&gt;&amp; data) { \treturn data.find(key) != data.end(); } <\/code><\/pre>\n<p>  \u0414\u0443\u043c\u0430\u044e \u043c\u044b\u0441\u043b\u044c \u044f\u0441\u043d\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0430.<\/p>\n<pre><code class=\"cpp\">\t\"some string\" in some_map <\/code><\/pre>\n<p>  \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"cpp\">\toperator_in(\"some string\", some_map) <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u0421\u0430\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 in \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">\t#define in *OP_IN_HELP{}* <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <b>OP_IN_HELP<\/b> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0438 \u0441\u043b\u0443\u0436\u0438\u0442 \u043d\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443.<\/p>\n<pre><code class=\"cpp\">\tclass OP_IN_HELP \t{};  \ttemplate&lt;class TIn&gt; \tOP_IN_LVAL&lt;TIn&gt; operator*(const TIn&amp; data, const OP_IN_HELP&amp;) \t{ \t\treturn OP_IN_LVAL&lt;TIn&gt;(data); \t} <\/code><\/pre>\n<p>   \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043b\u0435\u0432\u044b\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <b>OP_IN_LVAL<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u043b\u0435\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<pre><code class=\"cpp\">\ttemplate&lt;class TIn&gt; \tstruct OP_IN_LVAL \t{ \t\tconst TIn&amp; m_in;  \t\tOP_IN_LVAL(const TIn&amp; val) : m_in(val) \t\t{}; \t}; <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0432 \u043f\u043e\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 in, \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c.<\/p>\n<pre><code class=\"cpp\">\ttemplate&lt;class TIn&gt; \tstruct OP_IN_LVAL \t{ \t\tconst TIn&amp; m_in;  \t\tOP_IN_LVAL(const TIn&amp; val) : m_in(val) \t\t{};  \t\ttemplate&lt;class TWhat&gt; \t\tbool operator*(const TWhat&amp; what) const \t\t{ \t\t\treturn operator_in(m_in, what); \t\t} \t}; <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u043e\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a.<\/p>\n<pre><code class=\"cpp\">\tif (auto res = \"true\" in some_map) \t{ \t\tres-&gt;second = \"false\"; \t} <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0438\u043c\u0435\u043b\u0438 \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0415\u0441\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0434\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441++14, \u0434\u0440\u0443\u0433\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441++11.<\/p>\n<pre><code class=\"cpp\">\ttemplate&lt;class TIn&gt; \tstruct OP_IN_LVAL \t{ \t\tconst TIn&amp; m_in;  \t\tOP_IN_LVAL(const TIn&amp; val) \t\t\t:m_in(val) \t\t{};  \t\t\/\/ \u0412\u0435\u0440\u0441\u0438\u044f \u0434\u043b\u044f C++14 \t\ttemplate&lt;class TWhat&gt; \t\tauto operator*(const TWhat&amp; what) const  \t\t{  \t\t\treturn operator_in(m_in, what); \t\t}  \t\t\/\/ \u0412\u0435\u0440\u0441\u0438\u044f \u0434\u043b\u044f C++11 \t\ttemplate&lt;class TWhat&gt; \t\tauto operator*(const TWhat&amp; what) const -&gt; decltype(operator_in(m_in, what)) \t\t{ \t\t\treturn operator_in(m_in, what); \t\t}                  \/\/ \u0414\u043b\u044f \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440                 \/\/ \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e \u043d\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \t\ttemplate&lt;class TWhat&gt; \t\tauto operator*(TWhat&amp; what) const -&gt; decltype(operator_in(m_in, what)) \t\t{ \t\t\treturn operator_in(m_in, what); \t\t} \t}; <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 Visual Studio 2013 \u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0421++11 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0421++11 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432 \u0421++14, \u043f\u043e\u0442\u043e\u043c\u0443 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 in \u0434\u043b\u044f unordered_map.<\/p>\n<pre><code class=\"cpp\">template&lt;class TIterator&gt; class OpInResult { \tbool m_result; \tTIterator m_iter; public: \tOpInResult(bool result, TIterator&amp; iter) \t\t: m_result(result), m_iter(iter) \t{}  \toperator bool() \t{ \t\treturn m_result; \t}  \tTIterator&amp; operator-&gt;() \t{ \t\treturn m_iter; \t}  \tTIterator&amp; data() \t{ \t\treturn m_iter; \t} };   template&lt;class TKey, class TVal&gt; auto operator_in(const TKey&amp; key, std::unordered_map&lt;TKey, TVal&gt;&amp; data) -&gt; \tOpInResult&lt;typename std::unordered_map&lt;TKey, TVal&gt;::iterator&gt; { \tauto iter = data.find(key); \treturn OpInResult&lt;typename std::unordered_map&lt;TKey, TVal&gt;::iterator&gt;(iter != data.end(), iter); }  template&lt;class TKey, class TVal&gt; auto operator_in(const char* key, std::unordered_map&lt;TKey, TVal&gt;&amp; data) -&gt; \tOpInResult&lt;typename std::unordered_map&lt;TKey, TVal&gt;::iterator&gt; { \tauto iter = data.find(key); \treturn OpInResult&lt;typename std::unordered_map&lt;TKey, TVal&gt;::iterator&gt;(iter != data.end(), iter); } <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 <b>OpInResult<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 if. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u044f \u043f\u043e\u0434 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 unordered_map.find().<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"http:\/\/cpp.sh\/7rfdw\">cpp.sh\/7rfdw<\/a><\/p>\n<p>  \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. <br \/>  Visual Studio \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b \u0432 \u043c\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u0434\u043e \u043c\u0435\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <b>OP_IN_LVAL<\/b>. GCC \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0432 \u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f (\u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439), \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <b>OP_IN_LVAL<\/b>. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043e \u0447\u0451\u043c \u0440\u0435\u0447\u044c, \u0442\u043e \u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440. <a href=\"http:\/\/cpp.sh\/5jxcq\">cpp.sh\/5jxcq<\/a> \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u044f \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0435\u0440\u0435\u043d\u0451\u0441 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 in \u043d\u0438\u0436\u0435 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <b>OP_IN_LVAL <\/b>\u0438 \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 GCC (\u0435\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0444\u043b\u0430\u0433\u043e\u043c -fpermissive), \u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 Visual Studio.<\/p>\n<p>  \u0412 \u0421++17 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a.<\/p>\n<pre><code class=\"cpp\">\tif (auto res = some_map.find(\"true\"); res != some_map.end()) \t{ \t\tres-&gt;second = \"false\"; \t} <\/code><\/pre>\n<p>  \u041d\u043e \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"cpp\">\tif (auto res = \"true\" in some_map) \t{ \t\tres-&gt;second = \"false\"; \t} <\/code><\/pre>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435.<\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/github.com\/ChaosOptima\/operator_in\">github.com\/ChaosOptima\/operator_in<\/a><\/p>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <br \/>  \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<pre><code class=\"cpp\">\tnegative = FROM some_vector WHERE [](int x){return x  &lt; 0;}; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">P.S.<\/b><\/p>\n<div class=\"spoiler_text\">\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0442\u0435\u043c\u044b, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u043c\u044b\u0441\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0442\u0443\u0442? \u0418 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0430\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0448\u0442\u0443\u043a\u0438?<\/p>\n<p>  null-conditional operator<\/p>\n<pre><code class=\"cpp\">\tauto result = $if some_ptr $-&gt;func1()$-&gt;func2()$-&gt;func3(10, 11, 0)$endif; <\/code><\/pre>\n<p>  patern matching<\/p>\n<pre><code class=\"cpp\">\tsucces = patern_match val \t\twith_type(int x) \t\t{ \t\t\tcout &lt;&lt; \"some int \" &lt;&lt; x &lt;&lt; '\\n'; \t\t} \t\twith_cast(const std::vector&lt;int&gt;&amp; items) \t\t{ \t\t\tfor (auto&amp;&amp; val : items) \t\t\t\tstd::cout &lt;&lt; val &lt;&lt; ' '; \t\t\tstd::cout &lt;&lt; '\\n'; \t\t} \t\twith(std::string()) [&amp;](const std::string&amp;) \t\t{ \t\t\tcout &lt;&lt; \"empty string\\n\"; \t\t} \t\twith(oneof&lt;std::string&gt;(\"one\", \"two\", \"three\")) [&amp;](const std::string&amp; value) \t\t{ \t\t\tcout &lt;&lt; value &lt;&lt; \"\\n\"; \t\t} \t\twith_cast(const std::string&amp; str) \t\t{ \t\t\tcout &lt;&lt; \"some str \" &lt;&lt; str &lt;&lt; '\\n'; \t\t} \t\tat_default \t\t{ \t\t\tcout &lt;&lt; \"no match\"; \t\t}; <\/code><\/pre>\n<p>  string enum<\/p>\n<pre><code class=\"cpp\">\tStringEnum Power $def \t( \t\tPOW0, \t\tPOW1, \t\tPOW2 = POW1 * 2, \t\tPOW3, \t\tPOW4 = POW3 + 1, \t\tPOW8 = POW4 * 2, \t\tPOW9, \t\tPOW10 \t);  \tto_string(Power::POW0) \tfrom_string&lt;Power&gt;(\"POW0\") <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/419579\/\"> https:\/\/habr.com\/post\/419579\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419579\/\" class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438. \u041c\u043e\u0438\u043c \u0445\u043e\u0431\u0431\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u044f\u043a\u0438\u0445 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0448\u0442\u0443\u043a \u043d\u0430 \u0421++, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043c\u043d\u0435 \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0435\u0439 \u044f\u0437\u044b\u043a\u0430 \u043d\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u0432\u043b\u0435\u0447\u044c\u0441\u044f. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 in \u0435\u0441\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Python, JS. \u041d\u043e \u0432 \u0421++ \u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0432\u0435\u0437\u043b\u0438, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0435\u0433\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cpp\">\tstd::unordered_map&lt;std::string, std::string&gt; some_map =  \t{ \t\t{ \"black\", \"white\" }, \t\t{ \"cat\", \"dog\" }, \t\t{ \"day\", \"night\" } \t};  \tif (auto res = \"cat\" in some_map) \t{ \t\tres-&gt;second = \"fish\"; \t} <\/code><\/pre>\n<p>  <\/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-287528","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287528","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=287528"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287528\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}