【发布时间】:2014-04-03 01:27:10
【问题描述】:
我创建了一个简单的示例来展示我拥有什么样的数据结构:
#include "boost/variant.hpp"
struct Attribute {
boost::variant<vector<double>, vector<std::string>, vector<int64_t> > data;
std::string type;
};
struct Attribute a;
vector<double> vec;
vec.push_back(1);
vec.push_back(2);
a.data = vec;
a.type = "double";
vector<Attribute> attributes;
attributes.push_back(a);
我想知道我的vector<Attribute> attributes 超出范围后会发生什么。通常使用向量,每个元素都会调用析构函数,但如果这些元素的类型未知(如boost::any 或boost::variant)会发生什么?
【问题讨论】:
标签: c++ boost memory-leaks stdvector boost-variant