Placement new in gcc

Posted by Roman Prikhodchenko on Stack Overflow See other posts from Stack Overflow or by Roman Prikhodchenko
Published on 2010-04-08T20:36:34Z Indexed on 2010/04/08 20:43 UTC
Read the original article Hit count: 285

Filed under:
|

I need to find a workaround for a bug with placement new in g++. I now it was fixed in gcc-4.3 but I have to support versions 4.2 and 4.1. For example, following code compiles with an error

"error: no matching function for call to 'operator new(long unsigned int, void*&)"

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 >();

© Stack Overflow or respective owner

Related posts about gcc

Related posts about c++