I am trying to use my template class's Contains() method, but I am getting a strange argument conversion error.
error C2664: 'bool DynamicArray::Contains(const E) const' : cannot convert argument 1 from 'const Joint *' to 'Joint *const ' with E=Joint
Conversion loses qualifiers
Here is the relevant template class code.
template <class E>
class DynamicArray
{
bool Contains (const E element) const;
// Other code...
};
template <class E>
bool DynamicArray<E>::Contains(const E element) const
{
// Other code...
}
The call made to the Contains method is done so here
bool ASMState::AnimatesJoint(const Joint* pJoint) const
{
return m_animatedJoints.Contains(pJoint);
}
Relevant template class code in ASMState.h
class ASMState
{
DynamicArray<Joint*> m_animatedJoints;
// Other members...
bool AnimatesJoint(const Joint* pJoint) const;
// Other methods...
};
If I remove the const in the AnimatesJoint function signature like so, bool ASMState::AnimatesJoint(Joint* pJoint) const
then the code compiles. I would like to keep the const there if I can, but I do not know why that parameter seems to change from what I wrote. That is, from const Joint *
to Joint *const
according to the compiler.
I am using Visual Studio 2013 Express