Custom Class with auto_ptr<...> in TTree::Branch(...)

Hi,

I can compile code and Dictionaries cleanly. Unfortunately attempt to create Tree branch fails with:

Cannot find any ShowMembers function for auto_ptr

The code is as follows.

Event.h

[code]#include

class EventID;

class Event
{
public:
Event();

private:
std::auto_ptr _id;

};[/code]

Event.cpp

[code]#include “interface/EventID.h”
#include “interface/Event.h”

Event::Event()
{
_id.reset(new EventID());
}[/code]

EventLinkDef.h

[code]#include “interface/EventID.h”
#include “interface/Event.h”

#ifdef CINT

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class EventID+;
#pragma link C++ class std::auto_ptr;
#pragma link C++ class Event+;

#endif[/code]

Analyzer.cpp

... std::auto_ptr<Event> _event(new Event()); Event *event = _event.get() tree->Branch("event", &event, 32000, 0); ...

Code fails at tree->Branch(…)

What is wrong? I’d prefer to keep version with auto_ptr instead of working with raw pointers if possible.

thanks.

[quote]What is wrong? I’d prefer to keep version with auto_ptr instead of working with raw pointers if possible.[/quote]The I/O for auto_ptr is supported only in the trunk with revision 36548 and up.

Cheers,
Philippe.

Philippe,

I also happen to need to use auto_ptr’s. Any idea when it is going to become part of the stable release?

Hi,

It is part of v5.28 release last december.

Cheers,
Philippe.

Are you sure? I am getting an error.

11:44:~>"root"
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.28/00  14 December 2010   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] std::auto_ptr<int> a(new int(8))
Error: Symbol auto_ptr is not defined in current scope  (tmpfile):1:
Error: Symbol int is not defined in current scope  (tmpfile):1:
(const int)0
*** Interpreter error recovered ***
root [1] 

Hi,

Yes the problem as far as I know is corrected in that version of ROOT. What error do you see? Did you generate a dictionary for the auto_ptr?

Philippe.

Philippe,

I inserted the error output in the message above: Error: Symbol auto_ptr is not defined in current scope (tmpfile):1:

Hi,

Did you add #include
Did you follow the instruction at http://root.cern.ch/drupal/faq#n676 to generate the dictionary (if needed)?

Philippe.

Hi, thanks for the clarification. Once I included it all worked.