0030143: Foundation Classes - provide operator[] alias for NCollection_Array1, NColle...
authorkgv <kgv@opencascade.com>
Mon, 17 Sep 2018 10:14:00 +0000 (13:14 +0300)
committerkgv <kgv@opencascade.com>
Mon, 17 Sep 2018 10:16:42 +0000 (13:16 +0300)
src/NCollection/NCollection_Array1.hxx
src/NCollection/NCollection_Vector.hxx

index 91e2da2..09f6c29 100644 (file)
@@ -370,6 +370,9 @@ public:
   const TheItemType& operator() (const Standard_Integer theIndex) const
   { return Value (theIndex); }
 
+  //! operator[] - alias to Value
+  const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
+
   //! Variable value access
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
@@ -381,6 +384,9 @@ public:
   TheItemType& operator() (const Standard_Integer theIndex)
   { return ChangeValue (theIndex); }
 
+  //! operator[] - alias to ChangeValue
+  TheItemType& operator[] (Standard_Integer theIndex) { return ChangeValue (theIndex); }
+
   //! Set value 
   void SetValue (const Standard_Integer theIndex,
                  const TheItemType&     theItem)
index b54df7e..7594290 100755 (executable)
@@ -238,6 +238,9 @@ public: //! @name public methods
     return Value (theIndex);
   }
 
+  //! Operator[] - query the const value
+  const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
+
   const TheItemType& Value (const Standard_Integer theIndex) const
   {
     return *(const TheItemType* )findV (theIndex);
@@ -273,6 +276,9 @@ public: //! @name public methods
     return ChangeValue (theIndex);
   }
 
+  //! Operator[] - query the value
+  TheItemType& operator[] ( Standard_Integer theIndex) { return ChangeValue (theIndex); }
+
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
     return *(TheItemType* )findV (theIndex);