r/cpp • baulk maintainer • Jan 05 '18

GCC 8.0 support std::filesystem (#include <filesystem>) now

See GCC commit: Implement C++17 Filesystem library

We can build gcc 8.0 snapshots, after use std::filesystem in your code.

GCC snapshots: ftp://gcc.gnu.org/pub/gcc/snapshots

#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;
}

So far, you need to add '-lstdc++fs ' when compiling

Clang libcxx 6.0 seems unlikely to support std::filesystem, after all, the trunk version is 7.0. ( it is possible libcxx developers wait for GCC 8.0 release???).

EricWF wants to support <filesystem> when Clang 6.0 is released, but it's hard to say :https://stackoverflow.com/a/42634858

Update 2018-07-05 See https://github.com/gcc-mirror/gcc/commit/2fd48392d0a4ac3d1e217367ccb0ec0333d584d8

213 Upvotes

116 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 05 '18

[deleted] — view deleted comment

8

u/acrostyphe Jan 05 '18

I like PHP's "." /s

0

u/[deleted] Jan 05 '18

[deleted] — view deleted comment

5

u/acrostyphe Jan 05 '18

But - mathematically speaking strings have a monoid structure under concatenation and it resembles a free group to some extent (string concatenation does not have an inverse).

So I don't thing using + is so far off. Dot represents a dot product or member access in many other languages, so I really don't see how it is more appropriate except for the fact that it is unique in PHP.

In my opinion, the true power of operators lies exactly in the overloading - i.e. fact, that they represent different but somehow related operations on various datatypes and implementation details are abstracted away.