diff --git a/Foundation/include/Poco/Dynamic/Var.h b/Foundation/include/Poco/Dynamic/Var.h index 475f9f3f6..290df9076 100644 --- a/Foundation/include/Poco/Dynamic/Var.h +++ b/Foundation/include/Poco/Dynamic/Var.h @@ -435,8 +435,8 @@ public: return holderImpl, InvalidAccessException>("Not an array.")->operator[](n); else if (isStruct()) - return holderImpl, - InvalidAccessException>("Not a struct.")->operator[](n); + return structIndexOperator(holderImpl, + InvalidAccessException>("Not a struct."), n); else throw InvalidAccessException("Must be struct or array."); } @@ -447,11 +447,11 @@ public: /// returns true! In all other cases InvalidAccessException is thrown. { if (isArray()) - return const_cast(holderImpl, - InvalidAccessException>("Not an array.")->operator[](n)); + return holderImpl, + InvalidAccessException>("Not an array.")->operator[](n); else if (isStruct()) - return const_cast(holderImpl, - InvalidAccessException>("Not a struct.")->operator[](n)); + return structIndexOperator(holderImpl, + InvalidAccessException>("Not a struct."), n); else throw InvalidAccessException("Must be struct or array."); } @@ -545,6 +545,8 @@ private: throw E(errorMessage); } + Var& structIndexOperator(VarHolderImpl >* pStr, int n) const; + VarHolder* _pHolder; }; diff --git a/Foundation/src/Var.cpp b/Foundation/src/Var.cpp index bc40b44e3..84e19076d 100644 --- a/Foundation/src/Var.cpp +++ b/Foundation/src/Var.cpp @@ -477,4 +477,10 @@ std::string Var::toString(const Var& any) } +Var& Var::structIndexOperator(VarHolderImpl >* pStr, int n) const +{ + return pStr->operator[](n); +} + + } } // namespace Poco::Dynamic