Using luabind wrapped types as keys into lua tables

Greg Santucci <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Any type can be used as a key in a lua table, so I'd like to use
references to luabind wrapped types. The problem is that different lua
variables pointing to the same luabind C++ data are going to be seen
as different keys from the point of view of a lua table. For example:

mypin = c.pins:at(0)
mypin2 = c.pins:at(0)

pinmap = {}
pinmap[mypin] = "hello"
print(pinmap[mypin2]) -- Results in (null) printed.

-- But:

mypin = c.pins:at(0)
mypin2 = mypin
pinmap[mypin] = "hello"
pinr(pinmap[mypin2]) -- Results in "hello" printed, no problem

mypin and mypin2 can't be used as the same key from the point of view
of a lua table.

Is there a way to get to the raw data pointer, so that can be used as a key
instead?

Regards,
Greg Santucci

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.