diff -cr oommf12a3/app/oxs/base/util.cc oommf/app/oxs/base/util.cc *** oommf12a3/app/oxs/base/util.cc Fri Apr 5 18:29:23 2002 --- oommf/app/oxs/base/util.cc Mon Jun 9 21:37:53 2003 *************** *** 81,113 **** delete[] arr; } ! OxsTclObjConstPtrConstRef Oxs_TclObjArray::operator[](int index) const { #ifndef NDEBUG if(index>=size || index<0) { char buf[512]; Oc_Snprintf(buf,sizeof(buf), ! "const Tcl_Obj*& Oxs_TclObjArray::operator[] const: " "Array out-of-bounds; index=%d, size=%d", index,size); OXS_THROW(Oxs_BadIndex,buf); } #endif ! return static_cast(arr[index]); ! /// Brute-force the cast, which assumes that there is no storage ! /// difference between TclObj* and const TclObj*, at least in ! /// the indicated direction. This cast is needed by some compilers, ! /// which otherwise return a reference to a temporary, which is ! /// definitely *not* what we want! } ! OxsTclObjPtrRef Oxs_TclObjArray::operator[](int index) { #ifndef NDEBUG if(index>=size || index<0) { char buf[512]; Oc_Snprintf(buf,sizeof(buf), ! "Tcl_Obj*& Oxs_TclObjArray::operator[]: " "Array out-of-bounds; index=%d, size=%d", index,size); OXS_THROW(Oxs_BadIndex,buf); --- 81,108 ---- delete[] arr; } ! OxsTclObjPtr& Oxs_TclObjArray::operator[](int index) { #ifndef NDEBUG if(index>=size || index<0) { char buf[512]; Oc_Snprintf(buf,sizeof(buf), ! "Tcl_Obj*& Oxs_TclObjArray::operator[]: " "Array out-of-bounds; index=%d, size=%d", index,size); OXS_THROW(Oxs_BadIndex,buf); } #endif ! return arr[index]; } ! const OxsTclObjPtr& Oxs_TclObjArray::operator[](int index) const { #ifndef NDEBUG if(index>=size || index<0) { char buf[512]; Oc_Snprintf(buf,sizeof(buf), ! "const Tcl_Obj*& Oxs_TclObjArray::operator[] const: " "Array out-of-bounds; index=%d, size=%d", index,size); OXS_THROW(Oxs_BadIndex,buf); diff -cr oommf12a3/app/oxs/base/util.h oommf/app/oxs/base/util.h *** oommf12a3/app/oxs/base/util.h Mon Jul 8 20:51:30 2002 --- oommf/app/oxs/base/util.h Mon Jun 9 21:36:45 2003 *************** *** 48,56 **** //////////////////////////////////////////////////////////////////////// // Wrapper for Tcl_Obj** typedef Tcl_Obj* OxsTclObjPtr; - typedef OxsTclObjPtr& OxsTclObjPtrRef; - typedef const Tcl_Obj* OxsTclObjConstPtr; - typedef OxsTclObjConstPtr const & OxsTclObjConstPtrConstRef; class Oxs_TclObjArray { private: --- 48,53 ---- *************** *** 60,71 **** Oxs_TclObjArray(int arrsize); ~Oxs_TclObjArray(); ! OxsTclObjPtrRef operator[](int index); ! OxsTclObjConstPtrConstRef operator[](int index) const; ! /// It is not entirely clear to me whether the latter should return a ! /// constant reference to a constant pointer, or a constant reference ! /// to a non-constant pointer. We'll try the more restrictive ! /// approach first. -mjd, 19-Feb-2002. int Size() const { return size; } Tcl_Obj** Array() { return arr; } --- 57,64 ---- Oxs_TclObjArray(int arrsize); ~Oxs_TclObjArray(); ! OxsTclObjPtr& operator[](int index); ! const OxsTclObjPtr& operator[](int index) const; int Size() const { return size; } Tcl_Obj** Array() { return arr; }