指定 Boost Spirit X3 多重拷贝构造函数
Boost Spirit X3 multiple copy constructors specified
在 Microsoft Visual Studio 2017 和 2019 中使用 Boost 1.69.0 从 x3::variant 继承时,我收到一个烦人的警告:
warning C4521: 'boost::spirit::x3::variant<int>': multiple copy constructors specified
note: see reference to class template instantiation 'boost::spirit::x3::variant<int>' being compiled
这是由以下代码触发的:
#include "boost/spirit/home/x3/support/ast/variant.hpp"
struct si : boost::spirit::x3::variant<int> {};
int main() { si s; }
我该怎么做才能摆脱这个警告?
What can I do to get rid of this warning?
- 下载 Boost 1.70
- 全局禁用警告
- 通过在 Boost 包含之前暂时禁用它来抑制警告
- 告诉您编译器不要将 Boost 头文件视为您自己的头文件,而是将其视为系统头文件(在 GCC 中使用
-isystem-includes
而不是 -I
)
如果您必须坚持使用 1.69.0 并想在代码中修复它,您可以删除 spirit\home\x3\support\ast\variant.hpp
中的第 152-153 行
variant(variant& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_constructible<variant_type, variant_type&>::value))
: var(rhs.var) {}
(因为在第 149-150 行中定义了另一个带有 const 参数的复制构造函数)。
在 Microsoft Visual Studio 2017 和 2019 中使用 Boost 1.69.0 从 x3::variant 继承时,我收到一个烦人的警告:
warning C4521: 'boost::spirit::x3::variant<int>': multiple copy constructors specified
note: see reference to class template instantiation 'boost::spirit::x3::variant<int>' being compiled
这是由以下代码触发的:
#include "boost/spirit/home/x3/support/ast/variant.hpp"
struct si : boost::spirit::x3::variant<int> {};
int main() { si s; }
我该怎么做才能摆脱这个警告?
What can I do to get rid of this warning?
- 下载 Boost 1.70
- 全局禁用警告
- 通过在 Boost 包含之前暂时禁用它来抑制警告
- 告诉您编译器不要将 Boost 头文件视为您自己的头文件,而是将其视为系统头文件(在 GCC 中使用
-isystem-includes
而不是-I
)
如果您必须坚持使用 1.69.0 并想在代码中修复它,您可以删除 spirit\home\x3\support\ast\variant.hpp
中的第 152-153 行 variant(variant& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_constructible<variant_type, variant_type&>::value))
: var(rhs.var) {}
(因为在第 149-150 行中定义了另一个带有 const 参数的复制构造函数)。