------- Additional Comments From lars at trolltech dot com  2005-04-08 14:36 
-------
Hi Mark, 
 
(In reply to comment #3) 
> This code is invalid.  The use of ">>" requires the instantiation of the 
> declaration of the overloaded "operator>>", but that instantiation fails 
because 
> one of the template argument is anonymous. 
 
I don't see why the code is invalid. If you leave out the forward declaration 
of the template operator everything compiles fine, as the values in the 
anonymous enum get cast to integers, and the builtin operator>>(int, int) 
applies. 
 
So this compiles just fine (and to the correct code as far as I can tell): 
enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize };  
int verData(unsigned int data){ return (int)( (data & VMask) >> HSize ); }  
 
while this doesn't: 
 
class Base;  
template<typename Type>  
inline  Base const& operator>>(Base const& rConfiguration, Type& rType) ; 
enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize };  
int verData(unsigned int data){ return (int)( (data & VMask) >> HSize ); }  
 
The types in the forward declaration have no connection whatsoever with the 
values in the anonymous union, so the template should not apply. 
 
Lars 
 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19404

Reply via email to