2010-04-08 71 views
3

我需要为在g ++中放置新的bug找到解决方法。我现在已经在gcc-4.3中修复了,但我必须支持版本4.2和4.1。例如,下面的代码有错误编译在gcc中放置新东西

“错误:没有匹配函数调用“运营商新的(长无符号整数,无效* &)”

template<class T, template<typename> class Alloc> 
inline void* type_ctor() 
{ 
    Alloc<T> a; void* p = a.allocate(1); 
    new(p) T; 
    return p; 
} 

..... 

type_ctor<A, NewAllocator >(); 
+0

我有兴趣。你认为gcc-4.3中的哪个bug已经“修复”了这个问题?当我没有'#include '时,我肯定会在gcc-4.4中得到这个错误(如预期的那样)。 – 2010-04-08 20:46:24

+1

可能是早些时候一些常见的标准头文件包括''而现在它不? – UncleBens 2010-04-08 22:03:51

回答

10

要使用标准库布局new s,您必须#include <new>