C++列表在范围外插入迭代器
C++ List Insert Iterator Outside Range
首先,我是c++和list的新手,所以这可能很明显,我只是没有看到,对不起:(
我正试图创建一个文件列表,当我试图将第一个文件推送到列表时遇到了一个错误。调试断言错误消息为"列表插入迭代器超出范围"。
在头文件中,我有:
class ConfigDefFile
{
public:
ConfigDefFile( const char * dir_path, const char * file_name );
private:
ConfigDef * config;
static char filePath[ MAX_PATH + 1 ];
};
typedef list<ConfigDefFile *> ConfigDefFileList;
ConfigDefFileList def_files;
我将文件添加到列表的代码是:
char * root_path = NULL;
ConfigDefFile * def_file;
root_path = GetDefDir(); //Gets the root directory for the file.
def_file = new ConfigDefFile( root_path, file );
def_files.push_back( def_file ); //error occurs here
关于我正在做什么会导致这种情况,有什么想法吗?
您正在按照Igor的建议破坏堆。可能在的实施中
ConfigDefFile::ConfigDefFile(const char*dir_path,const char*file_name);
相关文章:
- 列表的有效性在插入后开始迭代器
- C++ 向量插入和迭代器混淆
- 在插入容器之前转换输出迭代器
- 插入 boost::multi_index 后迭代器变得无效?
- unordered_set范围插入与迭代器
- 如果迭代器没有因插入而无效,则使用std::find和C::insert()是线程安全的
- 使用条件迭代器插入到向量中
- 向量<pointer>:插入(迭代器,指针)插入垃圾值
- 并行STL插入迭代器,例如std :: back_insert_iterator
- unordered_map在结束迭代器上插入
- 重新插入元素可以"re-validate"迭代器吗?
- 插入新元素时结束迭代器会获得更新
- 使用迭代器将值插入嵌套地图
- 如何使用迭代器插入std ::列表
- 在 std::vector 中插入迭代器范围
- 如何普遍有效地填充缓冲液?(传递插入迭代器?器皿?等)
- 在范围 (C++) 之外列出插入迭代器
- 插入迭代器与容器的成员函数插入器
- C++列表在范围外插入迭代器
- 映射插入迭代器绑定