我正在使用Luan Pavlik与Lua 5.1的主发行版的luabind 0.9.1,在Win XP SP3上的cygwin +最新补丁x86,增强1.48,gcc 4.3.4.Lua和boost是cygwin预编译的版本.
我已经在静态和共享版本中成功构建了luabind.
两个版本都通过了test_object_identity.cpp测试的所有测试EXCEPT,这两个版本都失败了.
我已经将问题追溯到以下问题:如果为NON内置类创建表中的条目(即,不是int,string等),则无法检索该值.
这是一段代码,演示了这一点:
#include "test.hpp"
#include <luabind/luabind.hpp>
#include <luabind/detail/debug.hpp>
using namespace luabind;
struct test_param
{
int obj;
};
void test_main(lua_State* L)
{
using namespace luabind;
module(L)
[
class_<test_param>("test_param")
.def_readwrite("obj", &test_param::obj)
];
test_param temp_object;
object tabc = newtable(L);
tabc[1] = 10;
tabc[temp_object] = 30;
TEST_CHECK( tabc[1] == 10 ); // passes
TEST_CHECK( tabc[temp_object] == 30 ); // FAILS!!!
}
Run Code Online (Sandbox Code Playgroud)
tabc [1]确实是10而tabc [temp_object]不是30!(实际上,似乎是零)
但是,如果我使用iterate来遍历tabc条目,则有两个条目具有CORRECT键/值对.
有任何想法吗?
BTW,像这样重载==运算符:
#include <luabind/operator.hpp>
struct test_param
{
int obj; …Run Code Online (Sandbox Code Playgroud) 说我有一些课程模板:
template<typename T>
class {
// ....
}
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式为所有指针部分专门化这个模板:
template<typename T>
class<T *> {
// ....
}
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式专门为所有枚举专门模板吗?即,做类似的事情(虽然这不起作用)
template<typename T>
class<enum T> {
// ....
}
Run Code Online (Sandbox Code Playgroud) 尝试在以下段中使用is_class(从较大的段中删除),但它似乎不起作用.怎么了?
#include <type_traits>
template<typename U, typename = void>
struct xxxU_Impl
{
static void xxxU_push (const U& value);
};
template<typename U> void xxxU_push (const U& value) { xxxU_Impl<U>::xxxU_push (value); }
template<typename U>
struct xxxU_Impl<U *, typename std::enable_if<std::is_class<U>::value>::type>
{
static void xxxU_push (const U *& value) { }
};
class Foo
{
public:
int mFoo;
};
int main () {
Foo * pFoo = new Foo;
xxxU_push<Foo *>(pFoo);
}
Run Code Online (Sandbox Code Playgroud)
这是在cygwin上的gcc v4.7.2和gcc -std = c ++ 11 test.cpp命令行.
输出是:
test.cpp: In instantiation of …Run Code Online (Sandbox Code Playgroud)