关于在 c++ 中将文件路径存储在集合 STL 中
Regarding Storing file path in set STL in c++
我想存储目录和其中包含的文件。但是我无法将insert
功能用于SET STL
.我想忽略重复的目录,这些目录是由于同一位置的多个文件而出现的。下面是代码片段。我在插入功能时遇到错误。
using path_1 = std::string;
using paths_1 = std::set <path_1>;
void search()
{
for (recursive_directory_iterator i("."), end; i != end; ++i)
{
if (!is_directory(i->path()))
{
paths_1.insert(i->path().parent_path());
std::cout << i->path().parent_path() << "n";
}
if (!is_directory(i->path()))
{
files.push_back(i->path().filename());
// std::cout << i->path().filename() << "n";
}
}
for (auto f : files)
{
store_.save(f);
}
}
你必须有一个std::set
,像这样:
paths_1 my_paths;
然后使用该实例(而不是类型本身):
my_paths.insert(i->path().parent_path());
相关文章:
- 哪些存储了不完整类型的 STL 数据结构可以用作类成员?
- 如何复制存储在数组中的 STL 对象?
- 使用无序映射在STL中存储键值对
- 如何在 STL 容器中存储具有抽象模板类型的抽象模板化类?
- 如何使用 stl 容器有效地存储对象?(即根据其字段的值进行搜索)
- 如何删除在没有STL的队列中存储在数组中的第一个字符串元素
- 在C STL :: MAP内部节点中存储的内容
- 将 STL 映射存储到 Boost ConstBufferSequence 中
- 用于存储多种类型值的 STL 容器
- 将函子存储在 stl 映射中并调用它们
- 将指针存储在STL容器中,以供以后进行DealLocation
- 如何将模板对象存储在STL容器和成员功能调用中
- 保留存储在STL容器中的指针所指向的值(unordered_map)
- 如何在共享内存(C++)中存储stl对象
- 如何在C++中存储对 stl 容器元素的指针/迭代器引用
- 将值从STL矢量存储到另一个矢量
- 关于在 c++ 中将文件路径存储在集合 STL 中
- STL 按排序顺序存储数字
- 存储STL列表迭代器的指针安全吗?
- 如果使用 malloc 存储 STL 列表的分配内存,则运行时错误即将到来