[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Friend Template Errors in STL Containers



Howdy, list!

When I try to compile code using STL containers whose headers contain
friend template declarations, I get a compile-time error.  The code that
triggers this problem is an instantiation of any STL container whose
header file has friend templates.  For example, the code

map<int, int> theMap;

produces the following compile errors:

/usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include/g++-3/stl_map.h: In 
instantiation of `map<int,int,less<int>,allocator<int> >':
main.cpp:141:   instantiated from here
/usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include/g++-3/stl_map.h:206: 
template-id `operator <<>' for `operator <(const map<int,int,less<int>,
allocator<int> > &, const map<int,int,less<int>,allocator<int> > &)' does not 
match any template declaration
/usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include/g++-3/stl_map.h:205: 
template-id `operator ==<>' for `operator ==(const map<int,int,less<int>,
allocator<int> > &, const map<int,int,less<int>,allocator<int> > &)' does not 
match any template declaration

I've tried using the forward-declaration trick specified on gcc's faq,
but I get the same error (http://gcc.gnu.org/fom_serv/cache/32.html). 
I'm under some pretty intense deadline pressure and consequently don't
have time to investigate this thoroughly.  Anyone got a fix?

TIA!

jason harris



Reply to: