Boost logo

Boost :

Subject: Re: [boost] optional<optional<T>>
From: Andrew Bromage (ajb_at_[hidden])
Date: 2009-09-04 02:54:57


Andrei Alexandrescu <andrei <at>> 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, gregod at, cpdaniel at, john at