2 #include <luabind/luabind.hpp>
6 struct A
: counted_type
<A
>
9 struct B
: A
, counted_type
<B
>
12 struct test_implicit
: counted_type
<test_implicit
>
14 char const* f(A
*) { return "f(A*)"; }
15 char const* f(B
*) { return "f(B*)"; }
18 struct char_pointer_convertible
19 : counted_type
<char_pointer_convertible
>
21 operator const char*() const { return "foo!"; }
24 void func(const char_pointer_convertible
& f
)
28 } // anonymous namespace
30 void test_implicit_cast()
34 COUNTER_GUARD(test_implicit
);
35 COUNTER_GUARD(char_pointer_convertible
);
39 using namespace luabind
;
41 typedef char const*(test_implicit::*f1
)(A
*);
42 typedef char const*(test_implicit::*f2
)(B
*);
47 .def(constructor
<>()),
50 .def(constructor
<>()),
52 class_
<test_implicit
>("test")
54 .def("f", (f1
)&test_implicit::f
)
55 .def("f", (f2
)&test_implicit::f
),
57 class_
<char_pointer_convertible
>("char_ptr")
58 .def(constructor
<>()),
63 DOSTRING(L
, "a = A()");
64 DOSTRING(L
, "b = B()");
65 DOSTRING(L
, "t = test()");
67 DOSTRING(L
, "assert(t:f(a) == 'f(A*)')");
68 DOSTRING(L
, "assert(t:f(b) == 'f(B*)')");