Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm the original poster, just answering to say that I finally registered to StackOverflow. As such I have a new handle. Now saying thanks to the answers, in particular HeadGeek with the motivation issue. Also, to correct myself and folloiwing on tjm's comment, the exact form the code is used is not as I posted. The more correct way of using this method is to bring each operator into the class's own scope via <code>using</code>:</p> <pre><code>namespace scope { class MyClass { public: bool operator== (const MyClass&amp; that) { return compare_for_equality_somehow(that); } bool operator&lt; (const MyClass&amp; that) { return compare_for_lessality_somehow(that); } .... // using namespace std::rel_ops; // that one is incorrect }; using std::rel_ops::operator=!; // similarly for &gt;, &gt;=, &lt;= } // end of namespace </code></pre> <p>If done as in my original post, the header compiles fine, but compilation errors are brought when the header is included in a project that also includes and uses <code>rel_ops</code> somewhere. More importantly, that method would bring <em>all</em> operators for <em>all</em> classes defined in the class's scope -- definitively not desirable. With this approach of explicitly <code>using</code>, only the needed operators are brought into scope, and they are resolved as needed.</p> <p>Thanks everyone, seeing you soon.</p> <p>(<em>Also, please, don't upvote this question unless you really feel it has something to offer -- it is nothing new since Boost already has it -- I posted this for dual informative purposes</em>)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload