I have the following function but my compiler (VS2003) says that the assignement T = …. is illegal. Can someone clarify what I’ve done wrong? The type of value is a boost::variant. node is a struct.
template <typename T>
T find_attribute(const std::string& attribute)
{
std::vector<boost::shared_ptr<node> >::iterator nodes_iter = _request->begin();
for (; nodes_iter != _request->end(); nodes_iter++)
{
std::vector<node::attrib>::iterator att_iter = (*nodes_iter)->attributes.begin();
for (; att_iter != att_iter; (*nodes_iter)->attributes.end())
{
if ((*att_iter).key.compare(attribute) == 0) {
T = (*att_iter).value; //T : Illegal use of this type as an expression.
return T;
}
}
}
}
You should declare a variable: