[std-interval] C++ interval std

Guillaume Melquiond guillaume.melquiond at ens-lyon.fr
Thu Apr 6 10:18:14 PDT 2006


Le mercredi 05 avril 2006 à 12:53 -0600, Alan Eliasen a écrit :

> > Please note that our proposed interval type is meant to be a POD (plain
> > old data) type and as such has no copy constructor nor destructor. As a
> > consequence, on some architectures and with non-broken compilers, they
> > will behave no differently than if the function arguments were simply
> > integers; except that the register will probably be bigger, or two
> > registers will be used. When this happens, passing by value will be
> > faster than passing by const-reference. Indeed there is no architecture
> > such that foo(int) is slower than bar(int const &).
> 
>    As a "primitive" type, int is a different case than an object,
> though.

Int is indeed different from a non-POD type, but not that different from
a POD type; this is why I chose int as an example. As any other class, a
POD type has a copy constructor and a destructor for the sake of
language uniformity, but a compiler should _never_ call them. As a
matter of fact, it should not even generate them. And this is not a
matter of optimizing or not: this is explicitly the point of a POD type.
So even when all the optimizations are disabled, a real compiler will
not call a destructor on a POD object.

Best regards,

Guillaume



More information about the Std-interval mailing list