[Bug c++/33940] call of overloaded 'basic_string(const<anonymous class>&)' is ambiguous for a template member function
gzljg at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 29 17:56:00 GMT 2007
------- Comment #5 from gzljg at hotmail dot com 2007-10-29 17:56 -------
(In reply to comment #4)
> In practice, consider this:
>
> const
> class {
> public:
> template <class T> operator T() const
> {
> return int();
> }
>
> } MYNULLOBJECT = {};
>
> void f(int);
> void f(unsigned);
>
> int main()
> {
> f(MYNULLOBJECT);
> }
>
> No conforming compiler accepts it.
>
In this test case, "int" and "unsigned" are different class(thus causes
ambiguity in my view), while in the original test case, only ONE class
"std::string" involved---even with different type of constructors. Is it
sufficient for the compiler to pick up one from all its definitions? Such as ,
when we say "std::string s();" it knows which constructor it expects?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33940
More information about the Gcc-bugs
mailing list