Subject: Re: [boost] [type_traits] has_equal_to< std::vector<T> > alwaystrue_
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2011-10-22 16:32:18
On Oct 22, 2011, at 6:18 AM, Vicente J. Botet Escriba wrote:
> I'm not sure I understand the standard correctly. The standard says container requirements "Requires: T is EqualityComparable".
> Does this means that the operator== must not participate in overload resolution when the requirements are not meet, or that the compilation will fail?
> IMO, it is the first. In other parts of the standard the wording is more explicit. For example in the chrono part, every function that has some constraints in the template types, state something like:
> "Remarks: This operator shall not participate in overload resolution unless Rep2 is implicitly convertible to CR(Rep1, Rep2)."
The LWG did not intend that template functions be SFINAE'd unless it has a remark about not participating in overload resolution. And such treatment was reserved for cases that required such treatment to avoid ambiguities in overload resolution, templated constructors so that the std::traits would behave correctly (as has been noted in this thread), or (in the case of chrono) to control conversions to desired subsets (e.g. exactly convertible).
Newer parts of the standard were more likely to be treated in this way than older parts, with a notable exception being the "do the right thing clause" for the containers: [sequence.reqmts]/p14-15.
We did not add a "SFINAE" requirement to operator== for vector because we did not have a has_equal_to trait. Such a feature certainly seems plausible for a future standard, though it is always difficult to predict what will and won't pass through committee.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk