New to gcc

I need to find a workaround for the error with placing new in g ++. Now I have been fixed in gcc-4.3, but I need to support versions 4.2 and 4.1. For example, the following code compiles with an error

": there is no corresponding function to call the 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 >();
+3
source share
1 answer

To use the standard news library layout , you must #include <new>.

+10
source

Source: https://habr.com/ru/post/1740388/


All Articles