For some purposes we have a special string class derived from
std::wstring. Simplified declaration:
class cbstring: public std::wstring
{
public:
cbstring(const wchar_t* that): std::wstring(that) {}
cbstring(const std::wstring& that): std::wstring(that) {}
...
};
I want to return such objects from C++ as Python Unicode strings, e.g.:
cbstring produceWString()
{
return L"This is a test Unicode string";
}
If produceWString() returns std::wstring, the conversion happens by
magic. But with the cbstring return type, I get:
TypeError: No to_python (by-value) converter found for C++ type: class
cbstring
The corresponding conversion problem (passing u"Foo" from Python to a
function accepting const cbstring&) can be handled with the following
call in the extension module:
implicitly_convertible