Boost logo

Boost :

From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-11-02 06:05:10

In my design,

   - optional_poly<T> is default constructible and nullable
   - poly<T> is not default constructible and not nullable

The difference between the two is mainly in constructors and assignment

I don't think we can have a generic nonnullable<Z> that can select and
forward only the correct constructors. You have to specialize it for every
pointer-like class, so it doesn't simplify the developer work, and imposes
longer names (on average) on the users:
  optional_poly<T> becomes poly<T> (now nullable)
  poly<T> becomes nonnullable<poly<T> > (nonnullability is now explicit)

Making non-nullability explicit, though, adds the benefit that generic
interfaces can now explicitly request non-nullable arguments without knowing
the exact type of what's passed inside (e.g. poly vs. shared_ptr). The same
can be obtained in a design with different names by means of a trait
(is_nullable< >), and using enable_if, but it seems clumsier.

I'm fine with either approach.


On 11/2/07, shunsuke <pstade.mb_at_[hidden]> wrote:
> Corrado Zoccolo wrote:
> > Hi
> > I've uploaded a new version of the library in the vault: *
> >*
> > It now provides also a new class (poly<T>) that maintains the
> never-empty
> > guarantee.
> > poly<T> and optional_poly<T> share a large part of their implementation,
> so
> > I think it is sound to have both in the same library.
> Hmm, it seems inherent that poly is DefaultConstructible(Nullable), IMHO.
> Why not introduce `nonnullable`?
> nonnullable< poly<T> >
> nonnullable< boost::shared_ptr<T> >
> BTW, poly<void> can't be "any"?
> Regards,
> --
> Shunsuke Sogame
> _______________________________________________
> Unsubscribe & other changes:

dott. Corrado Zoccolo                          mailto:zoccolo_at_[hidden]
PhD - Department of Computer Science - University of Pisa, Italy
The self-confidence of a warrior is not the self-confidence of the average
man. The average man seeks certainty in the eyes of the onlooker and calls
that self-confidence. The warrior seeks impeccability in his own eyes and
calls that humbleness.
                               Tales of Power - C. Castaneda

Boost list run by bdawes at, gregod at, cpdaniel at, john at