[std-interval] default constructor

Sylvain Pion Sylvain.Pion at sophia.inria.fr
Wed Apr 5 18:03:11 PDT 2006


Here is the summary of the various options I saw:

1- no default constructor at all
2- [0,0]
3- empty
4- whole
5- uninitialized tag
6- see below (something a la "singular iterator")


1- does not seem reasonnable for the array argument.
2-,3-,4- seem not clearly distinguisable from each other.
5- may cause additional run-time overhead which I'm not
ready to pay.  However, let me suggest that this goes
in some "debug mode".

Let me propose 6-:

We can do something similar to the "singular values"
of standard iterators.  That is, the default constructed
value is considered "uninitialized", and the standard would
only allow assignment on such an uninitialized value.
Only assignment from a non-uninitialized interval makes
it non-uninitialized.  And all other operations on
uninitialized intervals have undefined behavior (which
means everything can happen including WWIII).

This way, we can simply use the default compiler-generated
default constructor, no particular value is specified.
This is optimal for efficiency.
And, a "debug mode" is allowed to store an "uninitialized tag"
in the intervals to abort in case of operations using such
uninitialized intervals.
Note that some STLs ship with a debug mode which adds some
validity checks to iterators and other classes.
This "debug mode" would not be specified by the C++ standard,
but allowed thanks to defining "uninitialized" and undefined
behavior.  It then becomes a QoI issue.


Would such a solution answer the requests for more "safety",
and keep others happy ?

-- 
Sylvain


More information about the Std-interval mailing list