sol2
sol2 copied to clipboard
Inheritance class, template class, how to bind
cpp code
template<class StringT>
class Request {
public:
StringT method ;
StringT url;
};
template<class StringT>
struct Response {
int statusCode = 0;
StringT body;
};
template<class StringT>
class HttpClient
{
public:
virtual Response<StringT> Get(StringT url) = 0;
};
class QHttpClient : public HttpClient<QString>
{
public:
QHttpClient();
~QHttpClient();
Response<QString> override;
}
lua code
local client=QHttpClient()
client:Get()
How to use the sol library to bind QHttpClient class to c++, note that it is an inherited abstract class,Request Response also needs to be bound