我用是1.64,应该是 optional relational operator出现就有这样的编译问题。
配置好编译出现报错:
1>------ 已启动生成: 项目: libluabind, 配置: Release Win32 ------
1>class.cpp
1>e:\gitee\lua\luabind\include\luabind\object.hpp(577): error C2672: “boost::operator ==”: 未找到匹配的重载函数
1>e:\gitee\lua\luabind\include\luabind\object.hpp(577): error C2784: “bool boost::operator ==(boost::none_t,const boost::optional<T> &) noexcept”: 未能从“const luabind::detail::basic_iterator<luabind::detail::basic_access>”为“const boost::optional<T> &”推导 模板 参数
1>d:\boost_1_64_0\boost\optional\detail\optional_relops.hpp(165): note: 参见“boost::operator ==”的声明
......
1>已完成生成项目“libluabind.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
查看
#define LUABIND_OPERATOR_ADL_WKND(op) \
inline bool operator op( \
basic_iterator<basic_access> const& x \
, basic_iterator<basic_access> const& y) \
{ \
return boost::operator op(x, y); \
} \
\
inline bool operator op( \
basic_iterator<raw_access> const& x \
, basic_iterator<raw_access> const& y) \
{ \
return boost::operator op(x, y); \
}
LUABIND_OPERATOR_ADL_WKND(==)//报错处
LUABIND_OPERATOR_ADL_WKND(!=)//报错处
那么需要改成匹配参数,如下
#define LUABIND_OPERATOR_ADL_WKND(op) \
inline bool operator op( \
boost::optional<basic_iterator<basic_access>> const& x \
, boost::optional<basic_iterator<basic_access>> const& y) \
{ \
return boost::operator op(x, y); \
} \
\
inline bool operator op( \
boost::optional<basic_iterator<raw_access>> const& x \
, boost::optional<basic_iterator<raw_access>> const& y) \
{ \
return boost::operator op(x, y); \
}
LUABIND_OPERATOR_ADL_WKND(==)
LUABIND_OPERATOR_ADL_WKND(!=)
ok
1>------ 已启动生成: 项目: libluabind, 配置: Release Win32 ------
1>class.cpp
1>class_info.cpp
1>class_registry.cpp
1>class_rep.cpp
1>create_class.cpp
1>function.cpp
1>open.cpp
1>stack_content_by_name.cpp
1>wrapper_base.cpp
1>libluabind.vcxproj -> E:\gitee\Lua\lua-5.1\liblua\Release\libluabind.lib
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========