|
Boost : |
Subject: Re: [boost] optional<optional<T>>
From: Andrew Bromage (ajb_at_[hidden])
Date: 2009-09-04 02:54:57
G'day.
Andrei Alexandrescu <andrei <at> metalanguage.com> writes:
> I'm defining an "optional" type for D's standard library modeled
> similarly to Boost.optional. An interesting question came up - should
> optional<optional<T>> fold itself into optional<T>, or is "double
> optional" an interesting concept of its own?
Automatically folding optional<optional<T>> doesn't make any more sense
than automatically folding vector<vector<T>>.
The reason is very simple: It's reasonable for templated code to use
optional<T> (where T is a template argument) for its own internal
purposes. This code should not misbehave just because a client wants
that template argument to be optional<U>.
Don't break parametricity without an extremely good reason.
Andrew Bromage
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk