Created
April 3, 2015 02:35
-
-
Save CinchBlue/e046c591e4d3e511d473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <sstream> | |
#include "lua.hpp" | |
#include "sol.hpp" | |
#include "Flexiglass.hpp" | |
template <typename T> | |
T unpack (boost::any& b) | |
{ | |
T result = boost::any_cast<T>(b); | |
return result; | |
} | |
int main() | |
{ | |
sol::state lua; | |
lua.open_libraries(sol::lib::base); | |
//Set boost::any object to a std::string value and pass it to Lua. | |
boost::any obj(std::string("hello")); | |
//This syntax should work here. I did a test case with a templated function. | |
lua.set_function("unpack", unpack<std::string>); | |
//Contents: | |
//print('Hello World!') | |
//unpack(b) | |
lua.open_file("test.lua"); | |
//The program outputs "Hello World" | |
//But fails at the unpack() method. | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment