使用clang编译libstdc++4.4.7和-std=c++0x时会失败
Compiling with clang fails with libstdc++4.4.7 and -std=c++0x
我正在尝试使用clang在旧的RHEL5机器上编译一些代码,该机器使用libstdc++4.4.7
。当我启用-std=c++0x
标志时,我得到:
/usr/lib/gcc/i386-redhat-linux6E/4.4.7/../../../../include/c++/4.4.7/bits/vector.tcc:380:19: error: call to implicitly-deleted copy constructor of
'value_type' (aka 'std::pair<double, double>')
value_type __x_copy = __x;
^ ~~~
/usr/lib/gcc/i386-redhat-linux6E/4.4.7/../../../../include/c++/4.4.7/bits/stl_vector.h:851:9: note: in instantiation of member function
'std::vector<std::pair<double, double>, std::allocator<std::pair<double, double> > >::_M_fill_insert' requested here
{ _M_fill_insert(__position, __n, __x); }
这是我在clang网站上应用补丁(修复了其他错误,但不是这个)之后。当我禁用-std=c++0x
它工作正常。听起来补丁可能没有解决所有的问题,这是一个已知的问题,有一个已知的修复?
补丁未完成。
Clang是正确的,代码是错误的:复制构造函数应该被删除,因为std::pair
声明了一个移动构造函数,但那是因为Clang正在实现最终的c++ 11规则,GCC 4.4头文件是为了使用GCC 4.4支持的早期版本的c++ 0x草案而编写的
您应该能够通过将此添加到std::pair
:
pair(const pair&) = default;
pair& operator=(const pair&) = default;
恢复隐式定义的复制操作,因此Clang不会删除它们。
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 为什么将boost::move()的返回值分配给非常数引用在C++0x模式下失败,但在C++03模式下有效
- 使用clang编译libstdc++4.4.7和-std=c++0x时会失败
- 如何检测转换是否在 c++0x 中失败