Template compilation problem
- From: Victor Bazarov <v.Abazarov@xxxxxxxxxxxx>
- Date: Fri, 14 Oct 2005 17:36:47 -0400
Dear VC++ experts,
--------------------------------------- This:
template <int L, int M, int T>
class Quantity
{
public:
Quantity(double = 0) {}
template<int L1, int M1, int T1, int L2, int M2, int T2>
friend Quantity<L1+L2,M1+M2,T1+T2> operator*
(const Quantity<L1,M1,T1>& q1, const Quantity<L2,M2,T2>& q2); // line 8
};template<int L1, int M1, int T1, int L2, int M2, int T2>
Quantity<L1+L2,M1+M2,T1+T2> operator*
(const Quantity<L1,M1,T1>& q1, const Quantity<L2,M2,T2>& q2) // line 13
{
Quantity<L1+L2,M1+M2,T1+T2> q;
return q;
}typedef Quantity<1,0,-2> Acceleration; typedef Quantity<1,0,0> Length;
const Acceleration GRAV(9.81); const Length penLen(1);
int main()
{
Quantity<2,0,-2> q = penLen * GRAV; // line 27
}
-------------------------------------------
does not compile with VC++ v8b2, saying the darndest thing:
~~~~~~~~~~~~~~~~~~~
..\test.cpp(27) : error C2593: 'operator *' is ambiguous
.\test.cpp(8): could be
'Quantity<L,M,T> operator *<1,0,0,1,0,-2>(const Quantity<1,0,0> &,
const Quantity<1,0,-2> &)'
[found using argument-dependent lookup]
with
[
L=2,
M=0,
T=-2
]
.\test.cpp(13): or
'Quantity<L,M,T> operator *<1,0,0,1,0,-2>(const Quantity<1,0,0> &,
const Quantity<1,0,-2> &)'
with
[
L=2,
M=0,
T=-2
]
while trying to match the argument list '(const Length, const Acceleration)'
~~~~~~~~~~~~~~~~~~~~~
How is it ambiguous if the two reported are the same? Is that their
ADL implementation contributing to this nonsense?
Any comment is mightily appreciated.
BTW, Comeau online compiles it without a problem.
V .
- Follow-Ups:
- Re: Template compilation problem
- From: John Carson
- Re: Template compilation problem
- From: Alex Blekhman
- Re: Template compilation problem
- Prev by Date: Re: Build Errors
- Next by Date: Re: Execute at Startup
- Previous by thread: Re: Problem with swprintf in VC++ 2003
- Next by thread: Re: Template compilation problem
- Index(es):
Relevant Pages
|