Original Post
Hello, I have a little problem. I declare a vector of a templated struct like so: *' to a 'TemplatedStruct *const & '. The push_back() function of the vector takes a 'const _Ty& _Val' type. What kind of value is push_back() expecting? Thanks, Slaru
template <typename T>
struct TemplatedStruct
{
T value;
};
std::vector<TemplatedStruct*> VectorOfTemplatedStructs;
Now, when I want to add a TemaplatedStruct to the vector, I am doing it like this:
// Add item with different type depending on the case
switch (theCase)
{
case CaseNumOne:
AddSettng<bool>(someValue);
break;
case CaseNumTwo:
AddSettng<int>(someValue);
...
}
// Add an item
template <typename ValType>
void AddSettng(ValType val)
{
// Insert into VectorOfTemplatedStructs
TemplatedStruct<ValType>* NewEntry = new TemplatedStruct<ValType>(val);
VectorOfTemplatedStructs.push_back(NewEntry); // !! Here's the error
}
On the line where I push the the TemplatedStruct onto the vector, the compiler (VC++ 2003) complains that it can't convert my 'TemplatedStruct