Background
If a third party library has code like
class ThirdPartyClass
{
public:
int value;
ThirdPartyClass(int i) : value(i) {}
ThirdPartyClass(const std::string& s) : value(0) {}
};
bool ThirdPartyFunction(int a, const ThirdPartyClass obj)
{
return a == obj.value;
}
Then it is possible to call like
ThirdPartyFunction(1, 1);
ThirdPartyFunction(1, std::string("Hello, World!"));
Question
Is it possible to extend this library (without modifying 3rd party code) to accept something like:
ThirdPartyFunction(1, "Hello, World!"); // const char* is not a string, implicit conversion fails
I want to avoid needing to write
ThirdPartyFunction(1, std::string("Hello, World!"));
The above is simplified: in my real example ThirdPartyFunction
is a stream operator and ThirdPartyClass
is a type wrapper that allows interaction with stream manipulators.