c++: template member function used in a different templated class
Hi,
I've a problem getting the following code to compile (boiled down to the minimum): Code:
#include <iostream> Code:
> g++ -o test test.cpp Code:
t->print<S>(); Code:
t->Foo::print<S>(); Thanks, matze |
Why not t->T::print<S>();? I don't see anything fundamental that would keep the name from being resolved, but it is an odd set of circumstances that isn't often used.
ta0kira |
Thanks, but I tried that and it does not work - it gives an identical error message :(
(The background is that I want to build a generic index where the key is to be defined in the template (just like S is used here) and is retrieved by a method that the used classes (T) share...) matze |
Maybe you should use an abstract class instead of a template in Foo? Being an index, there has to be something in common with all of them.
ta0kira |
The function is dependant on a template parameter, prefix with template
Code:
void operator()(T* t) { |
@ta0kira: I considered that (or specializing the template), as my classes share a parent class, but that would do it only as a temporary workaround.
@dmail: Thanks, that solved it. Thanks to both of you for your answers. matze |
All times are GMT -5. The time now is 11:30 PM. |