{"id":367157,"date":"2024-05-21T03:15:14","date_gmt":"2024-05-21T03:15:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=367157"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=367157","title":{"rendered":"<span>\u041a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f ordering \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043c\u043e\u0439 operator&lt;=&gt; \u0432 C++?<\/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>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043e \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/operator_comparison#Three-way%20comparison\" rel=\"noopener noreferrer nofollow\">\u00abspaceship operator\u00bb <\/a><code>operator&lt;=><\/code> (<a href=\"https:\/\/habr.com\/ru\/companies\/microsoft\/articles\/458242\/\" rel=\"noopener noreferrer nofollow\">[1]<\/a>, <a href=\"https:\/\/habr.com\/ru\/articles\/766976\/\" rel=\"noopener noreferrer nofollow\">[2]<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/yandex\/articles\/342354\/\" rel=\"noopener noreferrer nofollow\">[3]<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/pvs-studio\/articles\/465575\/\" rel=\"noopener noreferrer nofollow\">[4]<\/a>) \u0418 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0432\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043b\u043d\u043e\u0442\u0435. \u041d\u043e \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u043d\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442: <strong>\u0430 \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0430\u0448 <\/strong><code>operator&lt;=><\/code>, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438: <code>std::strong_ordering<\/code>, <code>std::weak_ordering<\/code> \u0438\u043b\u0438 <code>std::partial_ordering<\/code>? <strong>\u0418 \u043a\u0430\u043a\u0430\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430?<\/strong><\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u0434\u043b\u044f \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u044b\u0445:<\/p>\n<ol>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>strong_ordering<\/code>, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <code>a == b<\/code> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 <code>f(a) == f(b)<\/code> (\u0433\u0434\u0435 <code>f<\/code> \u0447\u0438\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <em>\u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/em> \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 <em>\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b<\/em>). \u0422\u043e \u0435\u0441\u0442\u044c, <strong>\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f <\/strong><code>operator==.<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>weak_ordering<\/code>, <strong>\u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e \u0445\u043e\u0442\u044c <\/strong><code>a == b<\/code><strong> \u0438 \u0434\u0430\u043b\u043e <\/strong><code>true<\/code><strong>, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <\/strong><code>a<\/code><strong> \u043e\u0442 <\/strong><code>b<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>partial_ordering<\/code>, <strong>\u0435\u0441\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a-\u043b\u0438\u0431\u043e \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b? \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432\u044b\u0448\u0435\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435!<\/p>\n<h2>\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448 \u0442\u0438\u043f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c<\/em>? <strong>\u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u043d\u0430\u0448\u0435\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438!<\/strong><\/p>\n<p>\u0415\u0433\u043e <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> (<\/strong><code>a == b<\/code><strong>) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>\u043d\u0435\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b <\/em><\/strong>(\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e <a href=\"#%D0%A0%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043b\u0435\u0435<\/a>)? \u041e\u043d <strong>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c <em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong>? \u0418\u0445 \u0432\u043e\u043e\u0431\u0449\u0435 <strong>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb, \u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb \u0438 \u00ab\u0440\u0430\u0432\u043d\u043e\u00bb<\/strong>? \u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u2014 \u0434\u0430, \u0434\u0430, \u0434\u0430, \u0442\u043e \u0432\u0430\u0448 \u0442\u0438\u043f <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439<\/em> \u0438 \u0435\u0433\u043e <code>operator&lt;=><\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <code>std::strong_ordering<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 <code>Person<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0436\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e \u0444\u0430\u043c\u0438\u043b\u0438\u0438, \u0434\u0430\u043b\u0435\u0435 \u2014 \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0434\u0430\u043b\u0435\u0435 \u2014 \u043f\u043e <abbr class=\"habraabbr\" title=\"\u0418\u041d\u041d \u2014 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430. \u041e\u043d \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0439 \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0420\u0424 \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.\" data-title=\"&lt;p>\u0418\u041d\u041d \u2014&amp;nbsp;&lt;strong>\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430&lt;\/strong>. \u041e\u043d \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0439 \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0420\u0424 \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.&lt;\/p>&#187; data-abbr=&#187;\u0418\u041d\u041d&#187;>\u0418\u041d\u041d<\/abbr>.<\/p>\n<pre><code class=\"cpp\">class Person {   string tax_ident;   string first_name;   string last_name; public:     std::strong_ordering operator&lt;=>(const Person&amp; rhs) const {       if (auto cmp = last_name &lt;=> rhs.last_name; cmp != 0) return cmp;       if (auto cmp = first_name &lt;=> rhs.first_name; cmp != 0) return cmp;       return tax_ident &lt;=> rhs.tax_ident;     } };<\/code><\/pre>\n<h2>\u0421\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p><em>\u0421\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435<\/em> \u0436\u0435 \u0442\u0438\u043f\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0445 <\/em>\u0442\u0438\u043f\u043e\u0432 \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u0445 <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c <em>\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b<\/em><\/strong>.<\/p>\n<p>\u0422\u0430\u043a, \u043a\u043b\u0430\u0441\u0441 <code>CaseInsensitiveString<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u0441\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c<\/em>: \u0445\u043e\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e <code>\"abc\" == \"aBc\"<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>true<\/code>, \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <code>\"abc\"<\/code> \u043e\u0442 <code>\"aBc\"<\/code>, \u0441\u0440\u0430\u0432\u043d\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>str<\/code>. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u0435\u0433\u043e <code>operator&lt;=><\/code> \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <code>std::weak_ordering<\/code>.<\/p>\n<pre><code class=\"cpp\">class CaseInsensitiveString {   string s; public:   std::weak_ordering operator&lt;=>(const CaseInsensitiveString&amp; rhs) const {     return case_insensitive_compare(s.c_str(), rhs.s.c_str());   }   std::string_view str() const { return s; } };<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u00ab\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u0438\u00bb<\/summary>\n<div class=\"spoiler__content\"><a class=\"anchor\" name=\"%D0%A0%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C\" id=\"\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u044c\"><\/a><\/p>\n<p>\u041f\u043e\u0434 \u00ab\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u044c\u044e\u00bb \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <code>operator&lt;=> <\/code>\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <\/strong>\u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <code>a<\/code> \u043e\u0442 <code>b<\/code> \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e <code>a == b<\/code> \u0432\u0435\u0440\u043d\u0443\u043b\u043e <code>true<\/code>.<\/p>\n<p>\u0422\u0430\u043a, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u0441\u0442\u0440\u043e\u0433\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c <code>Person<\/code>, <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c<\/strong> <code>a<\/code> \u043e\u0442 <code>b<\/code>, \u0435\u0441\u043b\u0438 <code>a == b<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0445\u043e\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438 \u043e\u043d \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0432\u0441\u0435 \u0438\u0445 \u0447\u043b\u0435\u043d\u044b <code>(tax_ident<\/code>, <code>first_name<\/code> \u0438 <code>last_name<\/code>; \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u0442\u0442\u0435\u0440\u044b<code>)<\/code> \u2014 \u043e\u043d \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0418, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0442\u0438\u043f <code>CaseInsensitiveString<\/code> (\u0434\u0430\u043b\u0435\u0435 \u2014 <code>CIS<\/code>) \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f<\/strong> <code>operator==: CIS{\"abc\"}<\/code> (\u043e\u0431\u044a\u0435\u043a\u0442 <code>a<\/code>)<code> == CIS{\"aBc\"}<\/code> (\u043e\u0431\u044a\u0435\u043a\u0442 <code>b<\/code>), \u043d\u043e <code>a.str() != b.str()<\/code>. \u0415\u0441\u043b\u0438 \u0431\u044b <code>CIS<\/code> \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043d \u0441\u0447\u0438\u0442\u0430\u043b\u0441\u044f \u0431\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c.<\/p>\n<\/div>\n<\/details>\n<h2>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>\u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <em>\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b<\/em><\/strong>, \u0438, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u0448 \u0442\u0438\u043f <strong>\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c <em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong>?<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u0441\u0435\u043c\u0435\u0439\u043d\u043e\u0433\u043e \u0434\u0440\u0435\u0432\u0430: \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/em> (<code>a == b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u0438 <code>b<\/code> \u2014 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a), <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb<\/em> (<code>a &lt; b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u2014 \u043f\u043e\u0442\u043e\u043c\u043e\u043a <code>b<\/code>) \u0438 <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb<\/em> (<code>a > b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u2014 \u043f\u0440\u0435\u0434\u043e\u043a <code>b<\/code>). <strong>\u041d\u043e<\/strong>, \u043a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <strong><em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b<\/em><\/strong>: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 <code>a<\/code> \u0438 <code>b<\/code> \u2014 \u0440\u0430\u0437\u043d\u044b\u0435 \u043b\u044e\u0434\u0438, \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u0440\u043e\u0432\u043d\u044b\u043c\u0438 \u0443\u0437\u0430\u043c\u0438.<\/p>\n<pre><code class=\"cpp\">class PersonInFamilyTree { public:   std::partial_ordering operator&lt;=>(const PersonInFamilyTree&amp; rhs) const {     if (this->is_the_same_person_as(rhs)) return partial_ordering::equivalent;     if (this->is_transitive_child_of(rhs)) return partial_ordering::less;     if (rhs.is_transitive_child_of(*this)) return partial_ordering::greater;     return partial_ordering::unordered;   } };<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 <em>\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/em> \u2014 <code>double<\/code> (\u0438\u043b\u0438 \u0436\u0435 <code>float)<\/code>. \u0425\u043e\u0442\u044c \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 (\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442) <em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/em>, <em>\u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb<\/em> \u0438 <em>\u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb<\/em>, \u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>NaN<\/code> <em>\u043d\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d<\/em>, <em>\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435<\/em> \u0438 <em>\u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435<\/em> \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e, \u0434\u0430\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e <code>NaN<\/code>.<\/p>\n<hr\/>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 \u0432\u0430\u0448\u0435\u0433\u043e <code>operator&lt;=><\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432 <code>std::strong_ordering<\/code>, <code>std::weak_ordering<\/code> \u0438 <code>std::partial_ordering<\/code>, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. <strong>\u0412\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b!<\/strong><\/p>\n<blockquote>\n<p>\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 <a href=\"https:\/\/t.me\/cppmoscow_info\" rel=\"noopener noreferrer nofollow\">C++ Moscow<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/791042\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0410 \u0432\u044b \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 spaceship operator \u0432 \u0441\u0432\u043e\u0435\u043c \u043a\u043e\u0434\u0435?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">18.18% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u0430<\/span><span class=\"tm-article-poll__answer-votes\">12<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 18.18%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">74.24% <\/span><span class=\"tm-article-poll__answer-label\">\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435\u0442<\/span><span class=\"tm-article-poll__answer-votes\">49<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 74.24%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">7.58% <\/span><span class=\"tm-article-poll__answer-label\">\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u0430<\/span><span class=\"tm-article-poll__answer-votes\">5<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 7.58%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 66 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 23 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/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\/articles\/791042\/\"> https:\/\/habr.com\/ru\/articles\/791042\/<\/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>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043e \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/operator_comparison#Three-way%20comparison\" rel=\"noopener noreferrer nofollow\">\u00abspaceship operator\u00bb <\/a><code>operator&lt;=><\/code> (<a href=\"https:\/\/habr.com\/ru\/companies\/microsoft\/articles\/458242\/\" rel=\"noopener noreferrer nofollow\">[1]<\/a>, <a href=\"https:\/\/habr.com\/ru\/articles\/766976\/\" rel=\"noopener noreferrer nofollow\">[2]<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/yandex\/articles\/342354\/\" rel=\"noopener noreferrer nofollow\">[3]<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/pvs-studio\/articles\/465575\/\" rel=\"noopener noreferrer nofollow\">[4]<\/a>) \u0418 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0432\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043b\u043d\u043e\u0442\u0435. \u041d\u043e \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u043d\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442: <strong>\u0430 \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0430\u0448 <\/strong><code>operator&lt;=><\/code>, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438: <code>std::strong_ordering<\/code>, <code>std::weak_ordering<\/code> \u0438\u043b\u0438 <code>std::partial_ordering<\/code>? <strong>\u0418 \u043a\u0430\u043a\u0430\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430?<\/strong><\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u0434\u043b\u044f \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u044b\u0445:<\/p>\n<ol>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>strong_ordering<\/code>, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <code>a == b<\/code> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 <code>f(a) == f(b)<\/code> (\u0433\u0434\u0435 <code>f<\/code> \u0447\u0438\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <em>\u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/em> \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 <em>\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b<\/em>). \u0422\u043e \u0435\u0441\u0442\u044c, <strong>\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f <\/strong><code>operator==.<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>weak_ordering<\/code>, <strong>\u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e \u0445\u043e\u0442\u044c <\/strong><code>a == b<\/code><strong> \u0438 \u0434\u0430\u043b\u043e <\/strong><code>true<\/code><strong>, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <\/strong><code>a<\/code><strong> \u043e\u0442 <\/strong><code>b<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 <code>partial_ordering<\/code>, <strong>\u0435\u0441\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a-\u043b\u0438\u0431\u043e \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b? \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432\u044b\u0448\u0435\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435!<\/p>\n<h2>\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448 \u0442\u0438\u043f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c<\/em>? <strong>\u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u043d\u0430\u0448\u0435\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438!<\/strong><\/p>\n<p>\u0415\u0433\u043e <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> (<\/strong><code>a == b<\/code><strong>) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>\u043d\u0435\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b <\/em><\/strong>(\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e <a href=\"#%D0%A0%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043b\u0435\u0435<\/a>)? \u041e\u043d <strong>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c <em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong>? \u0418\u0445 \u0432\u043e\u043e\u0431\u0449\u0435 <strong>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb, \u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb \u0438 \u00ab\u0440\u0430\u0432\u043d\u043e\u00bb<\/strong>? \u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u2014 \u0434\u0430, \u0434\u0430, \u0434\u0430, \u0442\u043e \u0432\u0430\u0448 \u0442\u0438\u043f <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439<\/em> \u0438 \u0435\u0433\u043e <code>operator&lt;=><\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <code>std::strong_ordering<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 <code>Person<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0436\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e \u0444\u0430\u043c\u0438\u043b\u0438\u0438, \u0434\u0430\u043b\u0435\u0435 \u2014 \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0434\u0430\u043b\u0435\u0435 \u2014 \u043f\u043e <abbr class=\"habraabbr\" title=\"\u0418\u041d\u041d \u2014 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430. \u041e\u043d \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0439 \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0420\u0424 \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.\" data-title=\"&lt;p>\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.&#187; data-title=&#187;&lt;p>\u0418\u041d\u041d \u2014&amp;nbsp;&lt;strong>\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430&lt;\/strong>. \u041e\u043d \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0439 \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0420\u0424 \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.&lt;\/p>&#187; data-abbr=&#187;\u0418\u041d\u041d&#187;>\u0418\u041d\u041d<\/abbr>.<\/p>\n<pre><code class=\"cpp\">class Person {   string tax_ident;   string first_name;   string last_name; public:     std::strong_ordering operator&lt;=>(const Person&amp; rhs) const {       if (auto cmp = last_name &lt;=> rhs.last_name; cmp != 0) return cmp;       if (auto cmp = first_name &lt;=> rhs.first_name; cmp != 0) return cmp;       return tax_ident &lt;=> rhs.tax_ident;     } };<\/code><\/pre>\n<h2>\u0421\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p><em>\u0421\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435<\/em> \u0436\u0435 \u0442\u0438\u043f\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 <em>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0445 <\/em>\u0442\u0438\u043f\u043e\u0432 \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u0445 <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c <em>\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b<\/em><\/strong>.<\/p>\n<p>\u0422\u0430\u043a, \u043a\u043b\u0430\u0441\u0441 <code>CaseInsensitiveString<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u0441\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c<\/em>: \u0445\u043e\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e <code>\"abc\" == \"aBc\"<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>true<\/code>, \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <code>\"abc\"<\/code> \u043e\u0442 <code>\"aBc\"<\/code>, \u0441\u0440\u0430\u0432\u043d\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>str<\/code>. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u0435\u0433\u043e <code>operator&lt;=><\/code> \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <code>std::weak_ordering<\/code>.<\/p>\n<pre><code class=\"cpp\">class CaseInsensitiveString {   string s; public:   std::weak_ordering operator&lt;=>(const CaseInsensitiveString&amp; rhs) const {     return case_insensitive_compare(s.c_str(), rhs.s.c_str());   }   std::string_view str() const { return s; } };<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u00ab\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u0438\u00bb<\/summary>\n<div class=\"spoiler__content\"><a class=\"anchor\" name=\"%D0%A0%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C\" id=\"\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u044c\">\u043c\u043e\u0441\u0442\u044c&#187;><\/a><\/p>\n<p>\u041f\u043e\u0434 \u00ab\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u044c\u044e\u00bb \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <code>operator&lt;=> <\/code>\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <\/strong>\u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c <code>a<\/code> \u043e\u0442 <code>b<\/code> \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e <code>a == b<\/code> \u0432\u0435\u0440\u043d\u0443\u043b\u043e <code>true<\/code>.<\/p>\n<p>\u0422\u0430\u043a, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u0441\u0442\u0440\u043e\u0433\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c <code>Person<\/code>, <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c<\/strong> <code>a<\/code> \u043e\u0442 <code>b<\/code>, \u0435\u0441\u043b\u0438 <code>a == b<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0445\u043e\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438 \u043e\u043d \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0432\u0441\u0435 \u0438\u0445 \u0447\u043b\u0435\u043d\u044b <code>(tax_ident<\/code>, <code>first_name<\/code> \u0438 <code>last_name<\/code>; \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u0442\u0442\u0435\u0440\u044b<code>)<\/code> \u2014 \u043e\u043d \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0418, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0442\u0438\u043f <code>CaseInsensitiveString<\/code> (\u0434\u0430\u043b\u0435\u0435 \u2014 <code>CIS<\/code>) \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0430\u0431\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f<\/strong> <code>operator==: CIS{\"abc\"}<\/code> (\u043e\u0431\u044a\u0435\u043a\u0442 <code>a<\/code>)<code> == CIS{\"aBc\"}<\/code> (\u043e\u0431\u044a\u0435\u043a\u0442 <code>b<\/code>), \u043d\u043e <code>a.str() != b.str()<\/code>. \u0415\u0441\u043b\u0438 \u0431\u044b <code>CIS<\/code> \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043d \u0441\u0447\u0438\u0442\u0430\u043b\u0441\u044f \u0431\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c.<\/p>\n<\/div>\n<\/details>\n<h2>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>\u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 <strong><em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <em>\u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c\u044b<\/em><\/strong>, \u0438, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u0448 \u0442\u0438\u043f <strong>\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c <em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0435<\/em> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong>?<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u0441\u0435\u043c\u0435\u0439\u043d\u043e\u0433\u043e \u0434\u0440\u0435\u0432\u0430: \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/em> (<code>a == b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u0438 <code>b<\/code> \u2014 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a), <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb<\/em> (<code>a &lt; b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u2014 \u043f\u043e\u0442\u043e\u043c\u043e\u043a <code>b<\/code>) \u0438 <em>\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb<\/em> (<code>a > b<\/code>, \u0435\u0441\u043b\u0438 <code>a<\/code> \u2014 \u043f\u0440\u0435\u0434\u043e\u043a <code>b<\/code>). <strong>\u041d\u043e<\/strong>, \u043a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <strong><em>\u043d\u0435\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b<\/em><\/strong>: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 <code>a<\/code> \u0438 <code>b<\/code> \u2014 \u0440\u0430\u0437\u043d\u044b\u0435 \u043b\u044e\u0434\u0438, \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u0440\u043e\u0432\u043d\u044b\u043c\u0438 \u0443\u0437\u0430\u043c\u0438.<\/p>\n<pre><code class=\"cpp\">class PersonInFamilyTree { public:   std::partial_ordering operator&lt;=>(const PersonInFamilyTree&amp; rhs) const {     if (this->is_the_same_person_as(rhs)) return partial_ordering::equivalent;     if (this->is_transitive_child_of(rhs)) return partial_ordering::less;     if (rhs.is_transitive_child_of(*this)) return partial_ordering::greater;     return partial_ordering::unordered;   } };<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 <em>\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/em> \u2014 <code>double<\/code> (\u0438\u043b\u0438 \u0436\u0435 <code>float)<\/code>. \u0425\u043e\u0442\u044c \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 (\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442) <em>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/em>, <em>\u00ab\u043c\u0435\u043d\u044c\u0448\u0435\u00bb<\/em> \u0438 <em>\u00ab\u0431\u043e\u043b\u044c\u0448\u0435\u00bb<\/em>, \u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>NaN<\/code> <em>\u043d\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d<\/em>, <em>\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435<\/em> \u0438 <em>\u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435<\/em> \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e, \u0434\u0430\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e <code>NaN<\/code>.<\/p>\n<hr\/>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 \u0432\u0430\u0448\u0435\u0433\u043e <code>operator&lt;=><\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432 <code>std::strong_ordering<\/code>, <code>std::weak_ordering<\/code> \u0438 <code>std::partial_ordering<\/code>, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. <strong>\u0412\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b!<\/strong><\/p>\n<blockquote>\n<p>\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 <a href=\"https:\/\/t.me\/cppmoscow_info\" rel=\"noopener noreferrer nofollow\">C++ Moscow<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/791042\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0410 \u0432\u044b \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 spaceship operator \u0432 \u0441\u0432\u043e\u0435\u043c \u043a\u043e\u0434\u0435?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">18.18% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u0430<\/span><span class=\"tm-article-poll__answer-votes\">12<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 18.18%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">74.24% <\/span><span class=\"tm-article-poll__answer-label\">\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435\u0442<\/span><span class=\"tm-article-poll__answer-votes\">49<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 74.24%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">7.58% <\/span><span class=\"tm-article-poll__answer-label\">\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u0430<\/span><span class=\"tm-article-poll__answer-votes\">5<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 7.58%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 66 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 23 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/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\/articles\/791042\/\"> https:\/\/habr.com\/ru\/articles\/791042\/<\/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-367157","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/367157","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=367157"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/367157\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=367157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=367157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=367157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}