Make shared_ptr_converter public.
[luabind.git] / test / test_tag_function.cpp
blob170545a6cce81760990f587bee488d0d16462899
1 // Copyright Daniel Wallin 2008. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include "test.hpp"
6 #include <luabind/luabind.hpp>
7 #include <luabind/tag_function.hpp>
8 #include <boost/bind.hpp>
10 int f(int x, int y)
12 return x + y;
15 struct X
17 int f(int x, int y)
19 return x + y;
23 void test_main(lua_State* L)
25 using namespace luabind;
27 module(L) [
28 def("f", tag_function<int(int)>(boost::bind(&f, 5, _1))),
30 class_<X>("X")
31 .def(constructor<>())
32 .def("f", tag_function<int(X&, int)>(boost::bind(&X::f, _1, 10, _2)))
35 DOSTRING(L,
36 "assert(f(0) == 5)\n"
37 "assert(f(1) == 6)\n"
38 "assert(f(5) == 10)\n"
41 DOSTRING(L,
42 "x = X()\n"
43 "assert(x:f(0) == 10)\n"
44 "assert(x:f(1) == 11)\n"
45 "assert(x:f(5) == 15)\n"