The following code compiles with GCC 4.9.2 but not with Clang 3.5.0:
#include
class Foo
{
public:
explicit operator std::string() const;
};
This seems to be a Clang bug. [over.match.list]/1:
When objects of non-aggregate class type
T
are list-initialized (8.5.4), overload resolution selects the constructor in two phases:
- [..]
- If no viable initializer-list constructor is found, overload resolution is performed again, where the candidate functions are all the constructors of the class
T
and the argument list consists of the elements of the initializer list.
Since the second line compiles fine, there is an inconsistency: They should be equivalent when it comes to overload resolution.