Re: Boost libraries and ROOT

From: troy d. straszheim <troy_at_resophonic.com>
Date: Wed, 16 Apr 2008 13:12:36 -0400


Kevin Lynch wrote:
> Antonio Augusto Alves Junior wrote:

>> Hello all,
>>
>> Please, can someone to give some example of usage of the Boost 
>> Libraries with ROOT?
>>
>> regards
>> Augusto
>>

>
> It's not clear what you are asking for. If you want to use Boost
> libraries and the Root libraries in compiled code, you won't have any
> issues. I do this all the time ... mostly I use stuff that ended up in
> TR1 (smart_ptr, tuple, bind, function, etc), but I've also been known to
> use multi_index, numeric_cast, random, and a few others. It all works
> just fine.

Unless you put ROOT objects on the ends of shared_ptrs... then you get the inevitable double-deletes. If you are a large group it can be hard to get the word out that one must treat ROOT objects differently (i.e. just let them leak) than nonroot objects. There is a rule of thumb that says 'either use shared_ptr exclusively, or not at all' and obviously this violates that.

But as you say, if you build/compile a library with a suitable (minimally templated or template-free) well-defined interface, this kind of thing can work fine.

> If you want to use some specific Boost library as interpreted code, then
> you will likely be in for a long, tough slog to get it working. Boost
> makes EXTREMELY heavy use of advanced template features, as well as lots
> of config headers and #ifdef'd workarounds for various compilers and STL
> implementations. You could modify all the headers and source files for
> the Boost libraries you want to use to include the relevant CINT magic
> (ClassDef/ClassImp and LinkDef.h files) and generate all the
> dictionaries, and then load them up.

"Don't even try" would be my recommendation.

> You'll have to do all this work if
> you want to persist Boost objects to TTrees/TFiles, since you need the
> dictionary in this case.

> Personally, I've never bothered with all that ... if the project is
> complicated enough that I need Boost, I'm going the compiled route
> anyway. And I just accept that I'm too lazy to put any Boost objects in
> TTrees or TFiles :-)

and if the requirement is simply storage, boost::serialization will handle just about anything. It eats templates for breakfast.

> Finally, a few years back, someone posted a message to roottalk about
> efforts to Rootify the Boost smart pointers .... I think it was called
> "ROOST". I haven't heard anything more since then, but perhaps there's
> been some more progress.

That was me. ROOST is long abandoned. It did 'work', but one must maintain lists of template instantiations, for the pointers themselves, and the casting operators (eg dynamic_pointer_cast<T>, const_pointer_cast<T>). Also automatic conversions if I remember correctly, ie shared_ptr<const T> => shared_ptr<T>... all anathema to me. There were a bunch of other reasons. Don't bother, it is just not the kind of thing you'd do interactively.

-t Received on Wed Apr 16 2008 - 19:12:48 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 16 2008 - 23:50:01 CEST