Take the 2-minute tour ×  If I do  Bat::Bat() : m_member_str(new
std::string("Am I freed?"))   throw std::runtime_error("oops");
Is the newly allocated std::string freed? I was thinking it
might be because the destructor is not called.  I am not using a
std::string, but my own class, just showing it as an easy
example.  share|improve this question Btw you would have to take
care of copy constructor and assignment operator in this class.
–  sharptooth Dec 28 '11 at 11:18 @sharptooth this class already
inherits from boost::noncopyable. –  unixman83 Dec 28 '11 at
11:26 Why would you ever want a std::string * member as opposed
to a std::string member? –  FredOverflow Dec 28 '11 at 16:36 add
comment  4 Answers  up vote 3 down vote accepted  This example
is the classic use case for smart pointers. Bat is not fully
constructed, so the destructor won't be called, but the
destructor for m_member_str and all other fully constructed
members will be. If you don't want an ugly block like try {
foo(); } catch (...) { dele