0

I have const correctness issue with QList.

I have a method getValue whose signature i cannot change returning const double and here

double vs = MinInput->getValue(0, 0);

vs is const.

I would like to build QList with results from this method and i get error C3892.

Since my list is a QList, cannot add const double (?)

Code is like that

    QList<double> minmax;
    for (int i = 0; i < 2*(3+othercutoffs_var_len) ; i++  )
        minmax.append( 0.0 );


    QSP< const VarInterface<double> > MinInput = ctx.getInputVar<double>(ctx.input(Id::fromString(QL1s("Min")))[0] );
    const double vs = MinInput->getValue(0, 0);
    minmax.at(0) = vs;

and this very last line of code is getting me into trouble. (other errors when filling the list with other such const doubles)

signature for getValue is like that

const TYPE & VarData<TYPE>::getValue( uint r, uint c ) const
4

2 に答える 2

3

正しいコードは次のようになると思います。

minmax[0] = vs;

アップデート:

QList::atconst変更できない参照を返します。

于 2013-04-11T07:44:10.503 に答える