【问题标题】:Boost interprocess fails on gcc 4.1.2gcc 4.1.2 上的 Boost 进程间失败
【发布时间】:2012-04-19 10:01:59
【问题描述】:

我正在尝试使用 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: 错误:模棱两可的类模板 struct pointer_to_other, char>

的实例化

.cc:144:错误: 候选者是:struct pointer_to_other, U>

.cc:158:错误:结构 指向其他指针,U>

.cc:167:错误:未定义类型的无效使用 âstruct pointer_to_other, char>

.cc:140:错误:âstruct 的声明 指向其他的指针, 字符>∧

在 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;

为了让它工作?

【问题讨论】:

    标签: c++ templates gcc


    【解决方案1】:

    这是一个编译器限制。根本不支持。

    【讨论】:

    • 能否请您添加一个确认此限制的来源。
    • @nikhil 哇,这是一年多以前的事了,我几乎不记得我在问什么,更不用说我是如何得出这个结论的了。
    • 哦,好吧,我也被类似的问题困扰了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-25
    • 2012-04-24
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 2015-06-13
    • 1970-01-01
    相关资源
    最近更新 更多