P
pveglia
Hi everyone,
i've got a problem with a template function member of a non-template
class. My code is the following:
class PropMap
{
private:
std::map<std::string, void*> properties;
public:
template<typename T>
T getProperty(std::string key)
{
return reinterpret_cast<T>(properties[key]);
}
T setProperty(std::string key, T value)
{
return reinterpret_cast<T>(properties[key] = value);
}
};
when i try to call the "getProperty" method:
int* i = getProperty<int*>("pos");
I get the error: "expected primary function". I think gcc doesn't know
that getProperty() is a template by I don't know why. Is there any
workaround to fix this?
Thank you very much.
Paolo
i've got a problem with a template function member of a non-template
class. My code is the following:
class PropMap
{
private:
std::map<std::string, void*> properties;
public:
template<typename T>
T getProperty(std::string key)
{
return reinterpret_cast<T>(properties[key]);
}
T setProperty(std::string key, T value)
{
return reinterpret_cast<T>(properties[key] = value);
}
};
when i try to call the "getProperty" method:
int* i = getProperty<int*>("pos");
I get the error: "expected primary function". I think gcc doesn't know
that getProperty() is a template by I don't know why. Is there any
workaround to fix this?
Thank you very much.
Paolo