【发布时间】:2010-08-08 23:41:10
【问题描述】:
我正在尝试编写一个函数来“字符串化”参数以用于记录目的。例如,我想写这样的东西:
vector<string> queries;
set<uint_8> filters;
LOG(INFO) << stringify<vector, string>(queries);
LOG(INFO) << stringify<set, uint_8>(filters);
这是我写的函数模板:
template <typename containerType, typename elemType>
string _stringify(const string name, const containerType<elemType> &elems) {
ostringstream os;
os << name << ": [";
BOOST_FOREACH(elemType elem, elems) {
os << elem << ",";
}
os << "]";
return os.str();
}
这是我收到的错误消息:error: ‘containerType’ is not a template
谢谢, 亚历克斯
【问题讨论】: