|
Boost : |
From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-08-16 00:27:56
I'd like to have the inhertance relationship added to shared_ptr. Attached
is a version of shared_ptr.hpp with the simple modification made.
Below is an example of usage:
#include <iostream>
#include <boost/shared_ptr.hpp>
class Root {};
class Child : public Root {};
typedef boost::shared_ptr<Root> HRoot;
typedef boost::shared_ptr<Child, boost::inherits<HRoot> > HChild;
// of course it can be done without the inherits class, but it is worth it
for the clarity
int main ()
{
try {
throw HChild (new Child);
}
catch (HRoot root) {
std::cout << "yay!" << std::endl;
}
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk