Saturday, 15 September 2012

c++ - C2663 - unable to see const vs nonConst issue -



c++ - C2663 - unable to see const vs nonConst issue -

i maintain receiving c2663 error while compiling next code. search on reveals c2663 points const/non-const mismatch, cant see problem in code.

the reduced code still reproduces error

template <class qtype> class qbound { public: qtype xminval, xmaxval, xvalstep, xcurrval; }; class qbounds { friend class qboundsholder; public: void add(const std::string & xp, const double xmin, const double xmax, const double xstep ); void add(const std::string & xp, const unsigned int xmin, const unsigned int xmax, const unsigned int xstep); void add(const std::string & xp, const int xmin, const int xmax, const int xstep ); private: std::vector<qbound<double>> xparametersdouble; std::vector<qbound<unsigned int>> xparametersuint; std::vector<qbound<int>> xparametersint; }; class qmultibounds { friend class qboundsholder; public: void add together (const std::string & xi, const std::string & xp, const double xmin, const double xmax, const double xstep ); void add together (const std::string & xi, const std::string & xp, const unsigned int xmin, const unsigned int xmax, const unsigned int xstep); void add together (const std::string & xi, const std::string & xp, const int xmin, const int xmax, const int xstep ); private: std::vector< std::pair< std::string, qbounds >> xdata; }; class qboundsholder { public: template <class qtype> void add together ( const std::string & xp, const qtype xmin, const qtype xmax, const qtype xstep); private: qmultibounds xparams; }; template <class qtype> inline void qboundsholder::add ( const std::string & xp, const qtype xmin, const qtype xmax, const qtype xstep) { this->xparams[0].second.add( xp, xmin, xmax, xstep ); };

with error beingness located on lastly line (i.e. this->xparams[0]...).

any help much appreciated, daniel

p.s. link minimum compilable solution reproduces problem here

qmultiparameterbounds::operator[] returns const std::pair<std::string, qparameterbounds>, qparameterbounds::addparameter not const.

you need add together non-const version of qmultiparameterbounds::operator[].

c++

No comments:

Post a Comment