79648730

Date: 2025-06-02 12:43:30
Score: 0.5
Natty:
Report link

I was just bitten by this today and thought I'd share my awful hacky work-around. It doesn't really answer your questions (I had the same questions), but my low reputation doesn't allow me just add a comment.

void test(std::filesystem::path const &p)
{
  std::cout << p << " -> " << std::filesystem::relative(std::filesystem::absolute(p)) << std::endl;
}

This does run a lot slower than the original, btw.

Alternatively, this may also work (but maybe not, or maybe not on all platforms (Windows specifically)):

void test3(std::filesystem::path const &p)
{
  std::cout << p << " -> " << std::filesystem::relative((p.string().starts_with('/') ? "" : "./") / p) << std::endl;
}

This version is not much slower than the original.

Reasons:
  • Whitelisted phrase (-1): I had the same
  • RegEx Blacklisted phrase (1.5): low reputation
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: user30697333