The function boost::filesystem::canonical()
(doc of 1.66, doc of current release) offers two arguments (ignoring the error code overload) base
. The first one is the path to canonicalize, the second argument is the base path used to make the first path absolute if it is relative. By default current_path() is used for this argument.
Boost 1.60 introduces some new functions, among them boost::filesystem::weakly_canonical()
(doc of 1.66, doc of current release). This function is missing this second argument. The same is true for the standardized (C++17) variants std::filesystem::canonical()
and std::filesystem::weakly_canonical()
(see cppreference).
I want to exchange canonical()
with weakly_canonical()
, but I used the second argument. That is how I realized that this argument was removed. Now I'm wondering why it was removed and how I can make the path absolute myself.
I found a defect report which hinted to this resolution for C++17, but frankly I don't really get the rationale. I'd be happy about an explanation or maybe better an example where the overload with base would be overspecified.
And of course I'm wondering how I then should convert a relative path into an absolute path using a base directory which is not the current directory. Should I simply use base / p
as hinted on cppreference for std::filesystem::absolute()
because I know that this is the correct form on my target system (Windows with Visual C++)?