I'm trying to return my C++ struct to lua using Swig and I want to have two constructors taking string or double as arguments.
struct MyType
{
MyType(const std::string & arg)
{
std::cout << "string constructor\n";
}
MyType(double arg)
{
std::cout << "double constructor\n";
}
}
In Lua running
MyType("3.14")
> double constructor
strInput = "3.14"
print(type(strInput))
> string
MyType(strInput)
> double constructor
What's more it looks like the string is parsed to double. So if I wanted to print argument from double constructor it would be 3.14.
Could there be any implicit conversion to double happening?