This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24011] ambiguous overload reported for no obvious reason
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Sep 2005 15:17:30 -0000
- Subject: [Bug c++/24011] ambiguous overload reported for no obvious reason
- References: <20050922150844.24011.andre_orwell@yahoo.com.au>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-22 15:17 -------
the error message about ambiguous overload is correct as there are two functions there.
operator* in the global namespace and operator* in the NS namespace.
You most likely wanted to implement operator* in the NS namespace and not a new one in the global
namespace.
The following code does what you wanted to do:
// Barebones code to reproduce the problem:
// Interface
namespace NS
{
template<typename T> class X {};
template<typename T> X<T> operator*(const X<T> &a, const X<T> &b);
}
// Implementation
template<typename T>
NS::X<T>NS::operator*(const NS::X<T> &a,const NS::X<T> &b)
{
return NS::X<T>();
}
// Application
int main(int argc, char *argv[])
{
NS::X<int> tmp = NS::X<int>() * NS::X<int>();
}
Notice how I wrote the Implementation.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24011