Standard placement operator

Sergey Grekhov grekhss at ...129...
Thu Mar 21 07:57:25 CET 2013


Dear, Norman Feske!

I am sorry for off-topic.
Is it possible to use STL containers using mentioned way? (change target.mk)
And one more question: how can one use STL containers with Genode new placement operator?

Thanks in advance for your answers.
Kind regards,
Sergey.

20.03.2013, 11:47, "Norman Feske" <norman.feske at ...1...>:
> Hello Daniel,
>
>>  [...] how do I use the std c++ new placement
>>  operator which take void *, i.e.
>>
>>  void * p = ::malloc(256);
>>  T * obj = new (p) T();
>>
>>  When I try to use this it cannot find the operator, only the Genode
>>  allocator version. I have 'cxx' in my target.mk
>
> in the rare cases where the Genode base system needs a placement new
> operator, we host it in the implementation file. For example,
> 'base/src/base/allocator/slab.cc' contains one. This way, the operator
> is defined only if really intended, which avoids using it by accident.
> It is a single line of code:
>
>   inline void *operator new(size_t, void *at) { return at; }
>
> Alternatively, if you are using the standard C++ library anyway, you may
> use the definition provided by libsupc++. Just specify your LIBS
> declaration in your 'target.mk' file as follows:
>
>   LIBS = libc libm stdcxx
>
> Now, you can just '#include <new>' and use the placement new operator
> provided there.
>
> Cheers
> Norman
>
> --
> Dr.-Ing. Norman Feske
> Genode Labs
>
> http://www.genode-labs.com · http://genode.org
>
> Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
> Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Genode-main mailing list
> Genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main

-- 
Best regards,
Sergey Grekhov




More information about the users mailing list