Const correctness and TBrowser

From: George Heintzelman (gah@bnl.gov)
Date: Thu Jan 13 2000 - 23:02:11 MET


Rooters,

I have just noticed something about the TBrowser class. The two main 
functions of the TBrowser, TBrowser::Add and TBrowser::GetSelected, 
take and return TObject *.

This means that I can't use the TBrowser class to type-safely browse 
const TObjects, being able to return const TObject *'s back when I've 
passed in originally a const TObject *.

My recommendation is to overload Add to take either a const or 
non-const TObject *, and then make GetSelected return a const TObject 
*, and write a GetSelectedUnconst (or some such name) which returns a 
non-const TObject * (and returns 0 if you've selected a const TObject). 
TBrowser internally would have to keep track of which TObject *'s are 
const and which non-const, of course.

George Heintzelman
gah@bnl.gov



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET