This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 22.214.171.124 [tuple.rel], 126.96.36.199 [allocator.globals], 188.8.131.52 [unique.ptr.special], 184.108.40.206 [util.smartptr.shared.cmp], 220.127.116.11 [time.duration.comparisons], 18.104.22.168 [time.point.comparisons], 23.13.5 [scoped.adaptor.operators], 22.214.171.124.13 [reverse.iter.op==], 126.96.36.199.13 [move.iter.op.comp] Status: New Submitter: Richard Smith Opened: 2015-02-07 Last modified: 2017-02-03
View other active issues in [tuple.rel].
View all other issues in [tuple.rel].
View all issues with New status.
The standard library specifies a lot of heterogeneous comparison operators. For instance:
template<class... TTypes, class... UTypes> constexpr bool operator!=(const tuple<TTypes...>&, const tuple<UTypes...>&);
This has an unfortunate consequence:
#include <tuple> #include <utility> using namespace std::rel_ops; std::tuple<int> a(0); bool b = a != a;
The last line here is ill-formed due to ambiguity: it might be rel_ops::operator!=, and it might be the heterogeneous tuple operator!=. These are not partially ordered, because they have different constraints: rel_ops requires the types to match, whereas the tuple comparison requires both types to be tuples (but not to match). The same thing happens for user code that defines its own unconstrained 'template<typename T> operator!=(const T&, const T&)' rather than using rel_ops.One straightforward fix would be to add a homogeneous overload for each heterogeneous comparison:
template<class... TTypes> constexpr bool operator!=(const tuple<TTypes...>&, const tuple<TTypes...>&);
This is then unambiguously chosen over the other options in the preceding case. FWIW, libstdc++ already does this in some cases.