24#if __cplusplus >= 201703L
26 namespace filesystem = std::filesystem;
29 template <
typename Mutex>
33 const filesystem::path& path,
34 const filesystem::path& base,
35 std::error_code& ec) {
36 return filesystem::relative(path, base, ec);
39#elif __cplusplus >= 201402L
41 namespace filesystem = std::experimental::filesystem;
44 template <
typename Mutex>
48 const filesystem::path& path,
49 const filesystem::path& base,
50 std::error_code& ec) {
54 const filesystem::path absolute_path = filesystem::absolute(path);
55 const filesystem::path absolute_base = filesystem::absolute(base);
57 auto path_it = absolute_path.begin();
58 auto base_it = absolute_base.begin();
60 while (path_it != absolute_path.end() && base_it != absolute_base.end() && *path_it == *base_it) {
65 filesystem::path result;
66 for (; base_it != absolute_base.end(); ++base_it) {
69 for (; path_it != absolute_path.end(); ++path_it) {
78 }
catch (
const filesystem::filesystem_error& error) {
80 return filesystem::path();
86 namespace filesystem = std::experimental::filesystem;
118 template <
typename Mutex>
122 const filesystem::path& path,
123 const filesystem::path& base,
124 std::error_code& ec) {
128 const filesystem::path absolute_path = filesystem::absolute(path);
129 const filesystem::path absolute_base = filesystem::absolute(base);
131 auto path_it = absolute_path.begin();
132 auto base_it = absolute_base.begin();
134 while (path_it != absolute_path.end() && base_it != absolute_base.end() && *path_it == *base_it) {
139 filesystem::path result;
140 for (; base_it != absolute_base.end(); ++base_it) {
143 for (; path_it != absolute_path.end(); ++path_it) {
147 if (result.empty()) {
152 }
catch (
const filesystem::filesystem_error& error) {
154 return filesystem::path();