提升进程间在 gcc 4.1.2 上失败
Boost interprocess fails on gcc 4.1.2
我正在尝试使用 Boost::Interprocess,但在尝试使用 gcc 4.1.2 进行编译时遇到了一些编译器错误。我缩小了代码范围,并设法在没有提升的情况下重现了问题。代码为:
#include <iostream>
static const std::size_t offset_type_alignment = 0;
template<class T, class U>
struct pointer_to_other;
template<class T, class U, template<class> class Sp>
struct pointer_to_other< Sp<T>, U >
/*144*/{
typedef Sp<U> type;
};
template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment>
class offset_ptr
{
};
template <class T, class DifferenceType = std::ptrdiff_t, class OffsetType = std::size_t, std::size_t Alignment = offset_type_alignment>
class offset_ptr;
template<class T, class T2, class T3, std::size_t A, class U>
/*158*/struct pointer_to_other<offset_ptr<T, T2, T3, A>, U >
{
typedef offset_ptr<U, T2, T3, A> type;
};
template<class VoidPointer>
class message_queue_t
{
typedef VoidPointer void_pointer;
/*167*/ typedef typename pointer_to_other<void_pointer, char>::type char_ptr;
};
int main()
{
/*177*/ message_queue_t< offset_ptr<void, std::ptrdiff_t, std::size_t, offset_type_alignment> > test;
}
我得到的错误:
.cc:实例化 message_queue_t>
.cc:177:从这里实例化
.cc:167:错误:类模板不明确 结构pointer_to_other的实例化,字符>
.cc:144:错误: 候选人是:结构pointer_to_other,U>
.cc:158:错误:结构 pointer_to_other, U>
.cc:167:错误:未定义类型的使用无效 "结构pointer_to_other,夏尔>
.cc:140:错误:结构声明 pointer_to_other, 查>
在 MSVS 中,这编译得很好。Ideone也可以编译,但它使用gcc 4.3.4。
重要
- 更改编译器是不可能的
- 我知道 Boost::Interprocess 没有用这个版本的 gcc 进行测试
我正在寻找的是一种解决方法。有什么想法吗?
PS - 模板是 boost 的一部分,但减少了,所以我无法真正更改它们。有什么方法可以改变:
message_queue_t< offset_ptr<void, std::ptrdiff_t, std::size_t, offset_type_alignment> > test;
为了让它工作?
这是一个编译器限制。它根本不受支持。
相关文章:
- gcc和c++17的过载解析失败
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 自定义对象的dlib序列化在gcc中失败
- GCC 4.8.2 自动矢量化由于 cout 而失败
- 调试模板时出现问题.专门针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 错误构建失败:模板参数 1
- C++正则表达式失败(GCC vs Microsoft 编译器)
- 带有引用的std::tuple在clang中编译失败,但在gcc中编译失败
- thread_local静态成员模板定义:初始化失败,GCC
- C++指向成员的指针的类内初始化会使 MSVC 失败(但 GCC/Clang 工作)
- 在 GCC 中工作的外行构造函数模板在 Clang 中失败
- enable_if is_same constexpr函数使MSVC失败(但在Clang,GCC中效果很好)
- GCC 模板参数推断/替换失败
- 为什么这段代码在Visual Studio中有效,但在gcc中失败
- 为什么将 lambda 用于非类型模板参数时 gcc 失败?
- 匿名结构可提高函数转换在GCC 5.4上失败
- 线性重载:为什么 clang 在 GCC 编译时失败?
- enable_if的模板专用化在 Clang 中失败,适用于 GCC
- 继承默认构造函数在 gcc 中失败并在 clang 中工作,哪个有错误?
- 为什么GCC中std::set的推导失败
- 为什么结构化绑定在 GCC 上失败