RE: [ROOT] streaming const members

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Sep 06 2002 - 20:34:56 MEST


Hi Christophe,

Indeed this is a bug.  It will be fixed shortly in the CVS repository.
In the meantime a work around is to do:

#ifndef __CINT__
	const 
#endif
	simpleNode* parent1;

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Christophe Delaere
Sent: Friday, August 30, 2002 8:03 AM
To: roottalk
Subject: [ROOT] streaming const members


Hi all,

I've just observed a strange feature (maybe a bug ?) when streaming
objects.
I've a rather simple class - let say simpleNode - designed to be part of
a const binary tree.

It looks like that (simplified) :

class simpleNode: public TObjArray
{
public:
	simpleNode(const simpleNode* n1, const simpleNode*
n2):parent1(n1),parent2(n2) {}
	~simpleNode() { if(parent1) delete parent1; if(parent2) delete parent2;
}
	const simpleNode* getParent(unsigned int n) const;
private:
	const simpleNode* parent1;
	const simpleNode* parent2;
}


I built an in-memory version of the tree, and I want to put it in a
TTree... and then it crashes.  When turning gDebug=2, I can see it
happens when it streams a NULL parent1 (for an end leaf).

The fact is that it seems that the problem arises because of the const
qualifier...
if it is removed (for members, and thus constructors) everything works
fine.

I don't know if it is a bug or a feature, but in the second case it
should be nice to mention it in the manual.


Cheers,
Christophe.


-- 
+-----------------------------------------------------------\|/---+
| Christophe DELAERE            office: e253               !o o!  |
| UCL - FYNU                    phone : 32-(0)10-473234    ! i !  |
| chemin du cyclotron, 2        fax   : 32-(0)10-452183     `-'   |
| 1348 Louvain-la-Neuve BELGIUM e-mail: delaere@fynu.ucl.ac.be    |
+-----------------------------------------------------------------+



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET