In the same way that iostreams has the forward-include header #include<iosfwd>
a header with declarations only, I assumed that Filesystems would have one too. However I couldn't find one.
I have a class that declares a single member function with filesystem::path const&
as argument and it seems an overkill to bring the whole of #include<experimental/filesystem>
just to get path
.
#include<experimental/filsystem_fwd> // or #include<experimental/filesystem/path/*only*/>
...
struct A{
...
void save(std::experimental::filesystem::path const& p);
}
Is there such a header? No.
Could you make such a header? Also, no. [namespace.std]/1 tells us:
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace
std
or to a namespace within namespacestd
unless otherwise specified.
Since any forward declarations of std
namespace things would have to be part of the std
namespace, you can't do that. You're allowed to write template specializations, and there are certain cases where you're allowed to poke at std
itself. But declaring std::filesystem::*
isn't something you can do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With