Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThe downside (of using `using namespace std::rel_ops;`) on the other hand is that all operators that define `==` will now also have an implicit `!=` even if there original author specifically did not create one (and if they did not create one they probably had a good reason (especially since it is so easy)).
      singulars
    2. COBetter than the `using namespace`, you can add `using ::std::rel_ops::operator!=; using ::std::rel_ops::operator>;...` for the operators that you need in the namespace of the type that you are defining. That will enable ADL to find it, but it still has the issue that Loki mentions: you cannot control by class, only by namespace. It is a pity that the standard did not add a tag type in the namespace, as that would have been simpler: `class MyType : ::std::rel_ops::tag {};` would bring all of the templates into scope for `MyType` without interfering with other types in the namespace.
      singulars
    3. CO(The option of using a tag type to enable of templated operators in a namespaces was suggested by Dietmar Kühl, although that was pre-C++11 `rel_ops`). An alternative (without using `std::rel_ops` I have played with in the past was abusing CRTP: `template <typename T> struct comparable { friend bool operator!=(T const& a, T const& b) { return !(a==b); }; friend bool operator> (T const& a, T const& b) { return b<a; }; ... class MyType : comparable<MyType> {}; /* provide op==, op< */` again in a separate namespace, and again ADL will find it by looking in the base class...
      singulars
 

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