Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2002-09-23 08:45:10


Howard Hinnant wrote:
[...]
> void foo(int n)
> {
> scoped_array<char> p(new char[n])
> ostrstream os(p.get(), n);
> ...
> }
>
> This is certainly less error prone than:
>
> void foo(int n)
> {
> move_array<char> p(new char[n])
> ostrstream os(p.get(), n);
> ...
> // accidently transfer p out before os destructs?
> ...
> }

void foo(int n)
{
      const move_array<char> p(new char[n])
      ostrstream os(p.get(), n);
      ...
}

Or am I just missing something?

regards,
alexander.


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