Boost logo

Boost Users :

From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2007-10-16 12:31:39


Hi,

The following program runs well in my system. However, if I change 1
to 0, it will terminate at the line with "delete". Does this mean that
boost::shared_ptr can tell if the pointer is from the stack or the
heap and does different things based on where the pointer is from?

Thanks,
Peng

#include <iostream>
#include <boost/shared_ptr.hpp>

int main() {
#if 1//try change this to 0
  int a[100];
  boost::shared_ptr<int> p(a);
  std::cout << std::endl;
#else
  int a[100];
  delete a; // would terminate here
  std::cout << std::endl;
#endif
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net