Boost logo

Boost :

From: David Rodríguez Ibeas (dibeas_at_[hidden])
Date: 2007-09-24 12:00:56


Just one small (and probably non-relevant) issue:

   I don't know the precise C++ answer, but in general you should be very
careful when comparing floating point numbers as you might get unexpected
results. An interesting article on this issue can be read here:

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

   David

On 9/22/07, Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
>
> Marco Servetto wrote:
> > The question is: C++ grants that
> > A a;
> > a.a2=8.8;
> > assert(reinterpret_cast<B*>(&a)->b2==8.8);
> >
> Please note that my reply is based on the final public review document
> and thus not authoritative.
> Yes, it grants this, according to the rules of layout-compatible PODs.
> > it is even true for classes with inheritance?
> >
> No. The layout-compatibility rules only apply to PODs. POD-structs are
> defined by their lack of member pointer members, reference members,
> object members of non-POD type (recursively), user-defined copy
> assignment and user-defined destructor.
> But there is one more requirement: they must be aggregate classes.
> Aggregate classes are defined in 8.5.1:
>
> "An aggregate is an array or a class with no user-declared constructors,
> no private or protected non-static data members, no base classes, and no
> virtual functions."
>
> Sebastian Redl
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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