Recently I was using functions in <filesystem>, e.g. std::filesystem::exists. These functions accept std::filesystem::path. I noticed passing const char* like "/abc" to function like std::filesystem::exists works, e.g. std::filesystem::exists("/abc")
My question is, it seems like when passing const char* to std::filesystem::exists, we are doing some implicit conversion from const char* to filesystem::path.
- Which constructor handles this on
filesystem::pathclass? - How can I write a constructor for this type of conversion? Below code doesn't seem to work, and I'm not sure what's wrong. (I'm a bit new to C++).
class A {
A(const char*& msg) {
std::cout << msg << std::endl;
}
};
void func(const A& p) {
}
int main(int argc, const char * argv[]) {
func("123"); // No matching function for call to 'func'
return 0;
}