|
Boost : |
Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-02-13 13:43:13
On Mon, Feb 13, 2012 at 5:25 PM, Andrzej Krzemienski <akrzemi1_at_[hidden]> wrote:
> Also, how would you implement it?
if (o1) os << *o1;
> what should an uninitialized optional
> print? Nothing? but how is having printed an uninitialized optional<int>
> different that not having printed anything?
> A question mark? but how would
> the following two be different:
They won't.
> If you propose to provide only output operation, then it looks like you
> want this for some sort of logging. But perhaps it is better to have some
> overloaded function toString() that converts all the types to strings.
Isn't that what << is for? :p
> Usually the string format that works for one program does not work for the
> other. And there appears to be no natural/intuitive way of representing any
> type (like optional) as text.
Right and that's not limited to optional.
Defining no IO seems ok too.
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk