Re: [eigen] Alignment of a derived class |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Am 19.07.2012 um 01:38 schrieb Gael Guennebaud:
> On Thu, Jul 19, 2012 at 6:48 AM, Christoph Hertzberg
> <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>> On 18.07.2012 23:29, Gael Guennebaud wrote:
>>>
>>> On Wed, Jul 18, 2012 at 4:18 AM, Martin Sälzle <martin.saelzle@xxxxxxx>
>>> wrote:
>>>>
>>>> struct Base
>>>> {
>>>> Eigen::Vector4f vec4f_base;
>>>> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
>>>> };
>>>>
>>>> struct Derived1 : public Base
>>>> {
>>>> Eigen::Vector4f vec4f_derived_1;
>>>> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
>>>> };
>>>> [...]
>>>>
>>>> The final question is what would happen for Derived1 if Base does note
>>>> have EIGEN_MAKE_ALIGNED_OPERATOR_NEW?
>>>
>>>
>>> On a 64bits system nothing special. On a 32bits system with SSE
>>> enabled, an abort or segfault if you create a Derived1 on the heap
>>> using "new Derived1".
>>
>>
>> Actually, if Derived1 still has an EIGEN_MAKE_ALIGNED_OPERATOR_NEW, it
>> should be ok to use `new Derived1`, shouldn't it?
>
> Sure!
>
> gael
>
>> Of course it is better to just add EIGEN_MAKE_ALIGNED_OPERATOR_NEW to the
>> base class -- and it won't harm if you add it to the derived classes as
>> well.
>>
>> Christoph
>>
>>
>>
>>
>>
>> --
>> ----------------------------------------------
>> Dipl.-Inf. Christoph Hertzberg
>> Cartesium 0.049
>> Universität Bremen
>> Enrique-Schmidt-Straße 5
>> 28359 Bremen
>>
>> Tel: +49 (421) 218-64252
>> ----------------------------------------------
>>
>>
>
>
Hi Gael,
I have another question:
I saw that you define
typedef void eigen_aligned_operator_new_marker_type;
in the macro
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF
in Memory.h
Do you have a structure in Eigen that checks if the typedef is defined, similar to the second example here:
http://en.wikipedia.org/wiki/SFINAE
If Eigen provides this I would not have to define it myself.
Basically what I want to do is to use boost::conditional to check if I have to use the aligned allocator for a vector.
thank you,
Martin