Boost logo

Boost :

Subject: Re: [boost] [XInt] review
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2011-03-09 15:30:39


On Wed, Mar 9, 2011 at 07:52, Chad Nelson <chad.thecomfychair_at_[hidden]> wrote:
> On Wed, 9 Mar 2011 09:41:58 -0500
> "Stewart, Robert" <Robert.Stewart_at_[hidden]> wrote:
>
>>> > magnitude_t:
>>> > * It probably needs to be POD for you to make assumptions
>>> > about the layout.
>>>
>>> The "struct hack" is a standard C idiom [...]
>>
>> A C struct is POD.
>
> So far as I've been able to determine, a C++ struct with some
> non-virtual functions, and that doesn't inherit from anything, acts
> like POD in every case. There's no need for a vtable or any other
> appended data that I've been able to imagine, and there certainly isn't
> on the two compilers I've directly tested (MSVC on Windows and GCC on
> Ubuntu Linux).
>

C++0x offers the definition of a "standard-layout class" in 9
[class]/7, with layout specified by 9.2 [class.mem].

Precise requirements:
— has no non-static data members of type non-standard-layout class (or
array of such types) or reference,
— has no virtual functions (10.3) and no virtual base classes (10.1),
— has the same access control (Clause 11) for all non-static data members,
— has no non-standard-layout base classes,
— either has no non-static data members in the most derived class and
at most one base class with non-static data members, or has no base
classes with non-static data members, and
— has no base classes of the same type as the first non-static data member.


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