Boost logo

Boost Users :

From: Michel André (yg-boost-users_at_[hidden])
Date: 2002-12-28 08:43:48


> Um, you can create a std::vector of a non-default-constructible object.
> It needs to be CopyConstructible, not DefaultConstructible. The only
> issue is that occasionally you may need to pass in a default
> initializer (e.g., when resizing (not reserving) or push_back-ing with
> no argument).
>
> Now, whether a date should nevertheless be default-constructible is
> another issue, but simply being able to put them in a vector is not an
> argument for it.

Well at first I was really suprised when the date class wasn't default
constructible (I expected it to be default constructible and set to
not_a_date, for me that would be the design with the least suprise), and I
usually expect most simple classes with value semantics to be default
constructible. But when I've used (and get used ;)) to the date class for a
while I really don't miss it and usually it isn't much pain to add the
explicit instantiation of the class either when using it in containers or as
variables. So my first reaction was to write to the list or to Jeff and ask
why but now I don't really care and can live with the design in either way.
But I guess for new users of the library would be least suprised if a
default constructor was supplied (instantiating date to not_a_date).

Regards
/Michel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net