This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33940] call of overloaded 'basic_string(const<anonymous class>&)' is ambiguous for a template member function
- From: "gzljg at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Oct 2007 17:56:13 -0000
- Subject: [Bug c++/33940] call of overloaded 'basic_string(const<anonymous class>&)' is ambiguous for a template member function
- References: <bug-33940-13880@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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