passing a reference to a primitive?

Cory Riddell <[email protected]> Tue, 06 Nov 2012 13:57:32 -0600
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
I've been working through some of the examples and I can't figure out
what's wrong.

I have a function that takes a reference to a double:

  void fn(double& value) {
    value += 3.4;
  }

I bind it with code that looks something like:

  module(L) [
    def("fn", fn)
  ]:

Then try to run it:
 
  luaL_dostring(
    L,
    "fval = 3.2\n"
    "fn(fval)\n"
  );

I get back an error that says something like:

  No matching overload found, candidates:
  void fn(custom [double]&)

I've tried being super-specific by binding fn like this:

  def("fn", (void(*)(double&)fn)

but I get the same result. I'm really trying to use the out_value
policy, but I can't even get this to compile:

  def("fn", fn, out_value(_1))

FWIW, I'm using VS2010.

I'm starting to wonder if I should just stick to the Lua's C api and try
to keep my dependencies to a minimum. Frankly, when I try to figure out
how luabind is working, it pretty much looks like magic.

The canonical version of luabind doesn't appear to be maintained any
more. I know some people on this list are maintaining forks and I'm
wondering if their version of luabind works for what I'm trying to do?
I've started to play with boost-python. It seems much heavier and more
complicated, but also more active.

Advice and suggestions welcomed!

Thanks,
Cory



------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d