forcecharlie
V2EX  ›  C

Visual Studio 2017 15.7 Preview 3 已经支持 std::filesystem 了

  •  
  •   forcecharlie · Apr 10, 2018 · 3439 views
    This topic created in 3132 days ago, the information mentioned may be changed or developed.

    半个多月前,就有消息说 msvc 将要支持 std::filesystem 了,后来更新 VisualCppTools Daily 发现已经支持了:

    https://www.reddit.com/r/cpp/comments/88mmjk/visualcpptoolscommunitydaily_can_support/

    微软官方博客:

    https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/

    而 GCC 在 8.0 也将支持 std::filesystem https://www.reddit.com/r/cpp/comments/7o9kg6/gcc_80_support_stdfilesystem_include_filesystem/

    现在没有进一步消息的只剩 libcxx 了。

    这意味着可以这样写文件系统相关的代码了:

    #include <iostream>
    #include <fstream>
    #include <filesystem>
    namespace fs = std::filesystem;
    
    int main()
    {
        fs::create_directories("sandbox/dir/subdir");
        std::ofstream("sandbox/file1.txt").put('a');
        fs::copy("sandbox/file1.txt", "sandbox/file2.txt"); 
        fs::copy("sandbox/dir", "sandbox/dir2"); 
        fs::copy("sandbox", "sandbox/copy", fs::copy_options::recursive);
        fs::remove_all("sandbox");
        return 0;
    }
    
    
    7 replies  •  2018-04-21 16:30:30 +08:00
    zhiqiang
    zhiqiang
    Apr 11, 2018 via Android
    1
    boost 早就有了,你们都不用 boost 的吗?
    zhiqiang
    zhiqiang
    Apr 11, 2018 via Android
    2
    对大多数人和项目而言,升级编译器比使用 boost 难多了。
    forcecharlie
    forcecharlie
    OP
    Apr 11, 2018
    3
    @zhiqiang std::filesystem 就是基于 boost 的,说实话并不想用 boost,而 asio 都是用的独立版。
    nyanyh
    nyanyh
    Apr 11, 2018
    4
    现在 C++什么都有了吗🌚感觉越发展越臃肿了
    P0P
    P0P
    Apr 11, 2018
    5
    可以考虑 qt
    timsensor
    timsensor
    Apr 11, 2018
    6
    很多年前就有了,不过是放在另一个命名空间
    我还是选择用 QT
    zhiqiang
    zhiqiang
    Apr 21, 2018
    7
    @forcecharlie 为什么不用 boost ?我听说二进制会变大,不知道会变大多少
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2154 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 02:59 · PVG 10:59 · LAX 18:59 · JFK 21:59
    ♥ Do have faith in what you're doing.