Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-08-20 13:21:48


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?

<.00002 wink>-ly y'rs,
dave

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk