I wanted to do some cross-platform, optional usage of std::filesystem
and used code like the below:
#ifdef __has_include
#if __has_include(<version>)
#include <version>
#endif
#endif
#ifdef __cpp_lib_filesystem
#include <filesystem>
// Use of std::filesystem::path
#endif
Then I can pass -std=c++11
or -std=c++17
and have or have not the support for filesystem.
This works fine almost everywhere but on a recent-ish OSX with no explicit target platform level set. This seems to default to some older OSX and throws a compile error:
error: 'path' is unavailable: introduced in macOS 10.15
...
Applications/Xcode_11.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/filesystem:739:24:
note: 'path' has been explicitly marked unavailable here
So how am I supposed to handle this on OSX without relying on configure checks if such code compiles? Wasn't the feature detection macro __cpp_lib_filesystem
meant to make such configure steps unnecessary?