Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-05 20:13:12

> Message du 06/05/11 02:00
> De : "Vladimir Batov"
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] [review] string convert
> > Matthew Chambers> writes:
> >
> > Did you ever use boost.convert on a non-defaultable type? I've never needed
> > that.
> It might come a surprise but non-defaultable types are the overwhelming majority
> of our classes. Easily 9:1. And I'd like to stress *our* classes and not just
> wacko-Vladimir's. And, yes, 'convert' is used well beyond ints and the like. The
> direction class in 'convert' documentation is a real class and we have plenty of
> similar ones not to mention considerably more complex. An enumerator as simple as
> enum hamlet_problem { to_be, not_to_be };
> has no default. I am not sure if extending the above to
> enum hamlet_problem { to_be, not_to_be, i_dont_know };
> will be helpful for poor Hamlet.

Think on bool. What is the value of bool()?

> From the design perspectives adding elements
> not relevant to the domain (i_dont_know) is pollution.
> I won't be surprised if you find a lot of non-defaultable types if you look
> closely around without pre-disposition that any class is supposed to have the
> default constructor. One needs to remember that the default constructor was
> introduced in C++ (if my memory serves me) so that objects would not be in an
> invalid state like 'int i;' can be. If one introduces the default constructor
> which does not, in fact, construct a valid object, then it seems to defeat the
> purpose.

I agree completely. Don't do that.


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