Question

I have the following classes:

template<class TYPE, class IDENTIFIER>
class Parameter
{
    TYPE typeValue;
    IDENTIFIER ID;
};

template<class IDENTIFIER>
class ParameterSystem
{
    template<typename TYPE>
    void AddParameter(Parameter<TYPE, IDENTIFIER> parameter, TYPE value);
};

However, whenever I try to use AddParameter, it says no function overload matches the argument list.I tried all sorts of possible combinations.For instance:

typedef unsigned int               ResourceIndex; //I use unsigned ints to reference resources in my other(resource system)
typedef unsigned int               DefaultParameterID;
typedef Parameter<ResourceIndex, DefaultParameterID>     ResourceParameter;

so then I use it like this:

ParameterSystem<DefaultParameterID> parameterSystem;
ResourceParameter param;
//do some stuff with param;
parameterSystem.AddParameter<ResourceIndex>(param, param.typeValue); //here it gives the error

And this doesn't work, Intellisense tells me it doesn't match the argument list, even tho it does.The argument list should be (Parameter, unsigned int) and that's what it is.What could I have done wrong?(For those interested, what AddParameter does is it takes the value of typeValue and sets it to a void pointer in a Map inside the parameter system and then it syncs the map key for that value with the ID of the parameter and the parameter also has a handle to it's parent parameter system, so from it's ID and a typecheck + typecast it can always get the parameter value in the system that responds to it's ID, but that shouldn't be relevant to the question I think...)

Was it helpful?

Solution

Try adding "typename" before the template type in the function's argument list:

void AddParameter(typename Parameter<TYPE, IDENTIFIER> parameter, TYPE value) {...}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top