Boost logo

Boost :

From: troy d.straszheim (troy_at_[hidden])
Date: 2004-08-07 05:41:18

Hi boost::

I have created a work derivative of the boost::shared_ptr and would
like boost's OK before I release this into the wild. Explanation:

I am on a large project, a neutrino telescope, that involves the ROOT
data analysis framework ( This is a large
package, one of whose features is a C++ interpreter. That's right, an
*interpreter*. You build shared objects describing your classes, load
them into the interpreter, and then you can run C++ *scripts*. The
ability to do all of this is absolutely insisted upon by my client, a
platoon of physicists. From what I can see this is almost a standard
in high-energy physics.

The general idea is that, if one inherits one's object from the ROOT
uber-object "TObject", and puts a macro into the class

class MyClass : public TObject {

    // whatever

   ClassDef(MyClass, 1); // this inserts "streamer" functions

then one can quite easily write these objects to disk, and use a whole
slew of introspection functions that come from TObject, like bool
InheritsFrom(string classname) and Browse().. well you get the idea.

One's code must make its way through a code generator, called
"rootcint" which adds a bunch of functions to the class. One then
specifies the template instances that one wants dictionaries for with

I managed to put together a hybridized boost::shared_ptr that works
with this framework. Objects that are inherited from the TObject that
contain boost::shared_ptr-s to other TObjects make the round trip
to/from disk with all reference counting and everything intact. Not a
small feat, if I may say so, and possibly of general interest to the
ROOT community.

This involved a hybridization of the no-member-templates shared_ptr and
the "regular" shared_ptr. rootcint is very idiosyncratic. Member
template friends don't work (I am told the fix is in CVS).
sp_enable_shared_from_this doesn't work. template member functions do,
for the most part, but the keyword volatile seems to confuse things.
You get the idea. the atomic_count stuff had to be taken out.
specializations of void didn't go through, if I remember correctly. I
removed most everything that was not necessary for linux/macosx and gcc
(our project's platforms).

I dislike "forking" code and doing merges, but I could not imagine that
boost itself would have any interest in supporting this toolkit's
interpreter, the #ifdefs would be nightmarish, and testing required the
framework itself, of course. I also could not leave the hybridized
version named "boost", as the full boost libraries remain in our
toolset, and anyway it would not be truth in advertising, I may very
well have introduced some bugs. With perl's help I named everything
"roost" (root/boost). I have left the comments intact at the tops of
the files and where applicable added my own. the boost license is of
course included. The documentation clearly states that this is a
ROOT-specific version of the boost::shared_ptr<>

Again, I just wanted to be sure this all was OK and give an opportunity
to before I release this into the wild. The tarball is at and runs tests with

./configure && make runtests

Which would require ROOT (, If you're interested, I
can give quick instructions on that offline, mail me directly.



Boost list run by bdawes at, gregod at, cpdaniel at, john at