提升侵入unordered_set在 1.48 中被打破,GCC 处于 C++11 模式
Boost Intrusive unordered_set broken in 1.48 with GCC in C++11 mode
如果你对GCC 4.7和Boost 1.48附带的Fedora 17进行普通安装,并使用C++11模式,Boost Intrusive的unordered_set就会被破坏。 在 GCC 4.6.2 和 Boost 1.47 附带的 Fedora 16 上,它可以工作。 这破坏了真实的代码,甚至破坏了官方文档中的示例:
#include <boost/intrusive/unordered_set.hpp>
using namespace boost::intrusive;
struct MyClass : public unordered_set_base_hook<>
{};
typedef unordered_set<MyClass>::bucket_type bucket_type;
typedef unordered_set<MyClass>::bucket_traits bucket_traits2;
int main()
{
bucket_type buckets[100];
unordered_set<MyClass> uset(bucket_traits2(buckets, 100)); // FAILS
}
错误消息:
/usr/include/boost/intrusive/hashtable.hpp:227:65:错误:使用已删除的函数'constexpr boost::intrusive::d etail::bucket_traits_impl>::type>::bucket_traits_impl(const boost::intrusive::d etail::bucket_traits_impl>::type>&('
在/usr/include/boost/intrusive/hashtable.hpp:30:0 包含的文件中, 来自/usr/include/boost/intrusive/unordered_set.hpp:18, 从 T.cpp:23:
/usr/include/boost/intrusive/detail/hashtable_node.hpp:80:8:注意:"constexpr boost::intrusive::d etail::bucket_traits_impl>::type>::bucket_traits_impl(const boost::intrusive::d etail::bucket_traits_impl>::type>&("被隐式声明为已删除,因为"boost::intrusive::d etail::bucket_traits_impl>::type>"声明移动构造函数或移动赋值运算符
这是它引用的代码,hashtable.hpp:227:
template<class BucketTraits>
bucket_plus_size(BOOST_FWD_REF(BucketTraits) b_traits)
: bucket_traits_(::boost::forward<BucketTraits>(b_traits))
{}
在 Boost 1.47 中,这是:
bucket_plus_size(const bucket_traits &b_traits)
: bucket_traits_(b_traits)
{}
默认情况下,我的系统上的BOOST_FWD_REF(TYPE)
定义为TYPE &&
,但如果定义了BOOST_NO_RVALUE_REFERENCES
,则它将变为const TYPE &
。 如果我以这种方式定义它,代码就会编译!
关于为什么会这样的任何想法? 是GCC的错,Boost的,Fedora的,还是我的错?
看起来像是 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53234 中描述的相同问题
即 Boost 1.48 假定 GCC 4.6 的旧行为,但 GCC 4.7 已更改以实现有关隐式定义的复制/移动构造函数的正确 C++11 语义。
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 奇怪的结构&GCC&clang(void*返回类型)
- 为什么在保护模式下继承升级不起作用
- GCC本机矩阵运算库
- PowerPC ppc64le上的Gcc Woverloaded虚拟错误
- 如何在全屏模式下(在OpenGL中)使背景透明
- gcc和c++17的过载解析失败
- 数据成员SFINAE的C++17测试:gcc vs clang
- GCC对可能有效的代码抛出init list生存期警告
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 为什么使用__LINE_的代码在发布模式下在MSVC下编译,而不是在调试模式下
- 为什么"S x({})"仅在GCC 7/C++1z模式下调用默认构造函数?
- GCC 在调试模式下崩溃,在发布模式下运行良好
- GCC 3.4 中奇怪的递归模板模式(确切地说是 MoSync)
- 提升侵入unordered_set在 1.48 中被打破,GCC 处于 C++11 模式
- 让GCC在C++11模式下在FreeBSD上工作
- GCC:抱歉,未实现:64位模式未在中编译
- GCC中包含的文件更详细的模式