Re: Create object in buffer w/ placement new?

From: Jonathan Turkanis (technews_at_kangaroologic.com)
Date: 03/24/04


Date: Wed, 24 Mar 2004 13:29:21 -0700


"Derek" <none@cheese.com> wrote in message
news:c3sol6$2c6h2r$1@ID-46268.news.uni-berlin.de...
> My understanding is that only operator new returns memory that
> is suitably aligned for any object. Does this mean that
> constructing an object in a buffer is not allowed unless that
> buffer was itself allocated by new?

There are other ways to guarantee alignment, but they are not 100%
standard conforming. See

   http://www.boost.org/doc/html/variant.misc.htm (portability)

   http://www.boost.org/libs/type_traits/index.html
(type_with_alignment)

The implementation is here:

   http://www.boost.org/boost/type_traits/type_with_alignment.hpp

Jonathan



Relevant Pages

  • Create object in buffer w/ placement new?
    ... My understanding is that only operator new returns memory that ... constructing an object in a buffer is not allowed unless that ... buffer was itself allocated by new? ...
    (comp.lang.cpp)
  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Discovering variable types...
    ... >memory it points to is on the heap. ... sequentially reading data, if one is randomly reading records, then a ... >project is what's prompting me to improve disk access. ... from a memory buffer I can do it in about a second. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Multicast Directshow Graph Bridging, COW Rustling, & the Use of Portable Holes in Cartoon Ph
    ... memory to share buffer pools across processes and works pretty well. ... You get two basic Direct Show filters, ... issue each GMF-source a virtual memory alias with COW ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: PCI bus-master and large contiguous memory buffers
    ... I built my scatter gather list in SRAM that was on my device, ... could have done it in system memory had I needed to. ... interrupt when a buffer was filled, the application would save the buffer to ... beginning of the recording I made a device IO control call to my driver. ...
    (microsoft.public.development.device.drivers)