我经常使用
boost::property_tree::ptree
,但我发现我创建、传递和保存副本的次数太多了。对于大型的ptree
对象来说,这是很昂贵的。
Boost 提供了一个swap函数,但没有移动构造函数。他们为什么要这样做呢?
我的当前解决方案是扩展ptree并自己创建一个:
class MyPtree : public boost::property_tree::ptree
{
MyPtree(MyPtree&& other)
{
swap(other);
}
... plus adding the other constructors and operators
};
这是最好的解决方案吗?还是我漏掉了什么?