In the second ~ec test, a feature of searching for names for operators in expressions arises: [over.match.oper] / 3 (from the "ancient" N3797):
For a unary operator @ with an operand of type whose cv-unqualified version is T1 [...]
The set of non-member candidates is the result of an unqualified search operator@ in the context of an expression in accordance with the usual rules for finding names in unqualified function calls, except that all member functions are ignored. However, if no operand has a class type, only those functions that are not members in the search set that have the first parameter of type T1 or "reference to (possibly cv-qualified) T1 " when T1 is the type of the enumeration of the [...] function candidate .
Therefore ::operator~(const Target&) should not be searched / used with a for expressions with a unary operator applied to an operand of type ConvertibleEC .
For the first, ~t , the operand has a class type, and the above exception does not apply.
Both the third and fourth tests do not use operator search, but a regular unskilled search. A regular unskilled search finds ::operator~(const Target&) (in cases 1 and 3) and anotherFunction (in case 4).
source share