Skip to content

Instantly share code, notes, and snippets.

@asryansergey
Last active February 13, 2022 15:38
Show Gist options
  • Save asryansergey/c14509d0d11b2df0b84d540ab73c7e03 to your computer and use it in GitHub Desktop.
Save asryansergey/c14509d0d11b2df0b84d540ab73c7e03 to your computer and use it in GitHub Desktop.
Easy way to construct filesystem paths with parameter pack.
#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