|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-08-20 13:42:33
----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, August 20, 2002 3:21 PM
Subject: Re: [boost] Generic construction
>
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
>
> > Well, at least this last part can be done with this helper wrapper, I
> think:
> >
> > template<class T>
> > class value_initialized
> > {
> > public :
> >
> > value_initialized() : x() {}
> > operator T& () { return x ; }
> >
> > private :
> > T x ;
> > } ;
> >
> > struct A
> > {
> > A() : x(0) {}
> > double x ;
> > } ;
> >
> > int main()
> > {
> > value_initialized<double> x_ ; double& x = x_ ;
> > cout << x << endl ;
> >
> > value_initialized<A> y_ ; A& y = y_ ;
> > cout << y.x << endl ;
> > }
> >
>
> Yep, that looks nice. Care to write it up and document it for the utility
> library?
>
OK.
If no one complains and/or have a better suggestion, I'll have it done by
late tomorrow.
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk