c++ - 我是否缺少 <experimental/filesystem> move 操作?

标签 c++ move

我是否缺少 move() 函数?我想出的最好的办法是硬链接(hard link)拷贝,然后删除原始拷贝,但这并不能让我充满信心,必须手动管理这两个操作,也不能跨文件系统工作。

最佳答案

这不叫 move ,而是叫重命名。

std::filesystem::rename

Moves or renames the filesystem object identified by old_p to new_p as if by the POSIX rename

 void rename(const std::filesystem::path& old_p,
             const std::filesystem::path& new_p);

 void rename(const std::filesystem::path& old_p,  // (since C++17)
             const std::filesystem::path& new_p,
             std::error_code& ec) noexcept; 

关于c++ - 我是否缺少 <experimental/filesystem> move 操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51097528/

相关文章:

带有计数的 for 和 while 循环中的 C++ 哨兵。陷入无限循环

python - 为什么 Python 在调用派生自 C++ std::vector 的 pybind11 type_cast-ed 类的方法时提示?

c++ - std::move - std::string - 内部指针

javascript - jquery, mouseenter 下移图片

c++ - 在 C++11 中,为什么不能在 std::move 之后使用 moved 变量?

c++ - 使用 lambdas 初始化多维数组

c++ - 控制台应用程序中的 QFileDialog::getOpenFileName

c++ - g++和gcc有什么区别?

C++ 不允许转换为右值引用

c++ - 如何使用C++中带有不可复制成员的initializer_list创建映射?