Boost logo

Boost :

Subject: Re: [boost] type_with_alignment.hpp / alignment_of.hpp too heavy
From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-10-01 12:48:10


On Wed, Oct 1, 2008 at 9:23 AM, Andrey Semashev
<andrey.semashev_at_[hidden]> wrote:
> Emil Dotchevski wrote:
>> I need to allocate an object of type T, but I also need to bundle it
>> in a single memory allocation with an object of class U. Something
>> like "new std::pair<T,U>" would work, except that U is a rather heavy
>> type and I want to pimpl it away into a cpp.
>>
>> This means that the cpp needs to deal with the alignment of T and U
>> when allocating the memory. For that purpose, I could use
>> type_traits/type_with_alignment.hpp in my header, but when I looked at
>> it, I was blown away by how much crap it includes (remember, I want my
>> header to be very very light.)
>
> Sorry if I'm missing something, but why would you need to include these
> headers in your header? Just forward-declare your internal pimpl class
> and define it in cpp. It is cpp where you would include
> type_with_alignment.hpp & co. and this is not that critical, is it?

The problem is that I still need the bootstrap code to be in the
header, it's a function template with a single parameter T. The header
needs to tell the cpp what's the size and alignment for T, and also
pass pointers to a function that can copy a T and a function that
destroys it. The cpp then can allocate the memory block, init the U
object and copy the T.

So, at least I need to include alignment_of.hpp which is so heavy it
practically nullifies my efforts to pimpl the U type away in the cpp.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk