|
Boost : |
From: Justin M. Lewis (boost_at_[hidden])
Date: 2003-05-03 22:48:34
----- Original Message -----
From: "Gregory Colvin" <gregory.colvin_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Saturday, May 03, 2003 8:43 PM
Subject: Re: [boost] Re: in/out parameters, codingstylesandmaintenance
> On Saturday, May 3, 2003, at 21:12 America/Denver, Justin M. Lewis
> wrote:
> > ...
> > A little bit of an overly simple example. How about something more
> > like
> >
> > void MyGetCWD(c_out<std::string> cwd)
> > {
> > char *buf = new char[FIRSTSIZE];
> > unsigned int size = FIRSTSIZE;
> > while(getcwd(buf, sizeof(buf)) == NULL)
> > {
> > delete [] buf;
> > size += step;
> > buf = new char[size];
> > }
> >
> > cwd = buf;
> > delete[] buf;
> > }
>
> Why not this?
>
> std::string GetCWD() {
> size_t size = FIRSTSIZE;
> boost::scoped_array<char> buf(new char[size]);
> while (!getcwd(buf,size))
> buf.reset(new char[size *= 2]);
> return std::string(buf);
> }
Yes, I knew someone would do something like that, that's why I made a 2nd
example, to make that harder to do. So, :P
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk