Last active
February 13, 2022 15:38
-
-
Save asryansergey/c14509d0d11b2df0b84d540ab73c7e03 to your computer and use it in GitHub Desktop.
Easy way to construct filesystem paths with parameter pack.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <filesystem> | |
#include <string> | |
namespace fs = std::filesystem; | |
template <typename... Args> | |
void join(fs::path& p, Args&&... args) { | |
((p /= std::forward<Args>(args)), ...); | |
} | |
template <typename... Args> | |
std::string constructPath(Args&&... args) { | |
fs::path result; | |
(join(result, args), ...); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment