Boost logo

Boost :

Subject: Re: [boost] optional<optional<T>>
From: Daniel Frey (d.frey_at_[hidden])
Date: 2009-09-03 03:09:07

On 03.09.2009, at 04:43, Andrei Alexandrescu wrote:

> 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?

I think optional<optional<T>> should not be folded into optional<T>.

One use-case occurs with databases. Consider "SELECT myint FROM
mytable WHERE mywhatever='foo'". When returning the result of such a
query, the C++ function that executed it could return an empty outer
optional if the database returned no row (WHERE-clause didn't match
anything), an empty inner optional when myint is SQL's NULL and the
integer value of myint in the then non-empty inner optional<int>

Regards, Daniel

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