[std-interval] C++ interval std

Gabriel Dos Reis gdr at integrable-solutions.net
Thu Apr 6 00:33:15 PDT 2006


Alan Eliasen <eliasen at mindspring.com> writes:

| Guillaume Melquiond wrote:
| > 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.  Please note that calling foo(Interval a) normally requires a
| call to a copy constructor and a call to the destructor if Interval is a
| class.

That is an abstract requirement -- remember the "as if rule".
In the real practice, I have not see any modern production C++
compiler run trivial destructor or trivial copy-constructor for POD,
i.e., they don't do anything beyond what they would have done for C
struct. 

People seem to focuse on what it costs to copy data in function call;
I would suggest that the focus should be what it costs to access data
when inside the called function.

-- Gaby


More information about the Std-interval mailing list