From: David Abrahams (dave_at_[hidden])
Date: 2008-05-26 19:33:36
on Mon May 26 2008, "Joachim Faulhaber" <afojgo-AT-googlemail.com> wrote:
> My first goal in boostifying my proposed interval template library
> (ITL http://sourceforge.net/projects/itl) was to provide good
> examples for interval_sets and interval_maps using boost::date_time
> objects. This was much harder than I had expected, because
> incidentally the most important syntactical and semantical
> requirements that I do rely on for a parameter T of itl::interval<T>
> are not provided by boost::date_time.
> The one property of boost::date_time that knocked my socks off was the
> default constructor that 'is-not-a-date-time'. I paraphrase this as:
> boost::time is lacking a big bang ;-)
> Default constructors in nearly all the types that I've seen in my
> lifetime (I know the realm of my unknown unknowns is vast ;-) are
> intended to be elements of the type they do construct.
Well, sure, but the built-ins in C++ generally default construct as
singular "degenerate" elements that you can assign to and destruct, and
> Moreover in so many cases including built in types, default ctors
> serve as *initial elements*. Other elements can be *reached* from T()
> applying operations of T on them.
> This applies to all built in types
You must be thinking of value-initialization. Please read
> and many std::types, like e.g. string, set, list etc. The most
> simple instance is unsigned int() with increment operation ++ that
> resembles the Peano axiomatic operations 0 and successor for natural
> This semantics of default ctors, at least in common built in and
> standard types and also in so many user defined types is so
> fundamental that I took it as a *semantical invariant* for the
> construction of my library.
Having a singular value definitely weakens the invariant of a type, but
that doesn't make it an invalid approach. It just means the invariant
is broader than it would be otherwise, and includes the possibility of
this singular value.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk