As explained in the documentation, the expected output of the following is:
boost::filesystem::path filePath1 = \"/home/user/\"; cout << filePath1.pare
You can use std::filesystem::canonical with C++17:
std::filesystem::canonical
namespace fs = std::filesystem; fs::path tmp = "c:\\temp\\"; tmp = fs::canonical(tmp); // will remove slash fs::path dir_name = tmp.filename(); // will get temp