围绕boost::ptree头疼的模板化类
Templated class around boost::ptree headache
我正在努力找出为什么使用以下代码片段的代码无法编译。可能有一些我不理解的类模板(即typedef typename的东西),但我不认为这是它在这个特殊的情况下。
template<typename data_type>
class GlobalStore {
private:
typedef boost::property_tree::basic_ptree<
std::string,
data_type,
std::less<std::string>
> _StorageTreeType;
_StorageTreeType _store;
public:
// snip
template<typename T>
const T Get(_StorageTreeType & st, const std::string & name)
{
return st.get<T>(name); //Compilation chokes here
}
};
我使用了完全相同的设置,尽管是在模板化类之外(但仍然使用与上面所示完全相同的行)。编译器(GCC/MingW)错误是
'>'
标记前期望的主表达式
如果我将T
替换为int
或该行上的其他内容,它仍然不会编译("int
之前的预期主表达式")。
任何想法吗?Boost::ptree文档在http://www.boost.org/doc/libs/release/boost/property_tree/ptree.hpp
变化
return st.get<T>(name);
return st.template get<T>(name);
关于->template
, .template
和::template
的语法是关于什么的? 相关文章:
- Boost Ptree访问第一个元素,没有路径名
- 如何使用C 将Boost Ptree插入MongoDB
- 如何使用Boost Ptree来解析像中国人这样的宽字节字符串?Boost版本是Boost_1_64_0
- 使用 Boost 'ptree.find' 无法按预期工作
- 跨多个线程的 Acess boost ptree
- 如何使用 boost 的 ptree 删除 XML 的属性?
- boost ptree的XML版本和编码
- 从boost::property_tree::ptree::迭代器获取ptree
- 如何使用 ptree(boost) 在 XML 文件中迭代具有相同名称的子项
- 使用BOOST::ptree生成注册表
- Boost PTree仅用于读取文件或存储值
- Boost ptree顶层数组
- Boost ptree add_child创建不需要的嵌套元素
- 是否需要清除重用的Boost ptree
- boost::ptree and the KeyCompare function?
- boost ptree:添加更多具有相同名称和属性的节点
- 如何手动创建带有XML属性的boost ptree
- 使用Boost ptree解析std::string
- 围绕boost::ptree头疼的模板化类
- Boost ptree动态修改值数组