在gcc上升级进程失败4.1.2

问题描述:

我正在尝试使用Boost :: Interprocess,但在尝试使用gcc 4.1.2编译时遇到一些编译器错误。我缩小了代码范围,并设法在没有提升的情况下重现问题。该代码是:在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: In instantiation of message_queue_t >

.cc:177: instantiated from here

.cc:167: error: ambiguous class template instantiation for struct pointer_to_other, char>

.cc:144: error: candidates are: struct pointer_to_other, U>

.cc:158: error: struct pointer_to_other, U>

.cc:167: error: invalid use of undefined type âstruct pointer_to_other, char>

.cc:140: error: declaration of âstruct pointer_to_other, char>â

在MSVS,该编译罚款。 Ideone也编译好,但它使用gcc 4.3.4

重要

  • 改变编译器出了问题
  • 我知道的boost ::

我正在寻找的进程间未用此版本的gcc测试因为是解决方法。有任何想法吗?

PS - 模板是增强的一部分,但减少了,所以我不能真正改变它们。有什么办法可以改变:

message_queue_t< offset_ptr<void, std::ptrdiff_t, std::size_t, offset_type_alignment> > test; 

为了使它工作?

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

+0

请问您可以添加一个确认此限制的来源。 – nikhil 2013-05-20 14:26:48

+0

@nikhil这是一年多的时间,我几乎不记得我在问什么,更不用说我是如何得出这个结论的。 – 2013-05-20 14:40:25

+0

好的,我被一个类似的问题困住了。 – nikhil 2013-05-21 05:05:05