Boost logo

Boost :

From: Ralf W. Grosse-Kunstleve (rwgk_at_[hidden])
Date: 2006-03-09 18:21:39


--- me22 <me22.ca_at_[hidden]> wrote:

> Though that would suggest adding auto_array, which is something whose
> use shouldn't be encouraged, imho...

Could you please explain why?

What is your solution for the situation in my original posting? Here it is
again, this time with auto_array:

  auto_array<int>
  foo(unsigned size)
  {
    auto_array<int> result(new int[size]);
    // do something to result
    // if an exception is thrown result will be cleaned up
    return result;
  }

  void
  bar()
  {
    auto_array<int> foo_result(foo(1000));
    // code is still exception safe
  }

Note that I don't want reference counting overhead (shared_array) or the
overhead associated with std::vector (two pointers instead of just one, default
construction on resize or lots of push_backs, deepcopy semantics).

Ralf

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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