Indeed exists path_iterator. But if you want elegance:
#include <boost/filesystem.hpp>
int main() {
for(auto& part : boost::filesystem::path("/tmp/foo.txt"))
std::cout << part << "\n";
}
"/"
"tmp"
"foo.txt"
for(auto& part : boost::filesystem::path("/tmp/foo.txt"))
std::cout << part.c_str() << "\n";
/
tmp
foo.txt