Sol2: Register STL Container to Lua

Created on 15 Jul 2016  路  3Comments  路  Source: ThePhD/sol2

Hi, is it possible to register a (generic) STL Container to Lua, such as std::vector<>? I've registered some C++ types as usertypes and some of them return std:vector<>& of different types. But they are only exposed as usertype, not as table - so I cannot iterate them.

Is there a solution on this or is it not possible, yet?

Bike.Shed Bug.Well Shit

All 3 comments

All types which contain a begin() and end() that are iterators are automatically pushed as tables into Lua. This includes vector, map, unordered_map, list, deque, BASICALLY every std:: container ever.

Albeit, now that you've mentioned this I am envisioning a bug with returning a reference to a vector and reference semantics being applied internally, making it push a userdata instead of the table semantics I just described.

... Oops. I'll fix that right away.

Awesome!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sagunkho picture sagunkho  路  4Comments

spin-scenario picture spin-scenario  路  8Comments

Koncord picture Koncord  路  4Comments

morsisko picture morsisko  路  3Comments

squeek502 picture squeek502  路  3Comments