持っている:
std::map<const int, float> m_areaCost;
私は以下をコンパイルしようとしています:
inline float getAreaCost(const int i) const {
return m_areaCost[i];
}
これにより、次のエラーが発生します。
error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>' (or there is no acceptable conversion)
以前は、呼び出し時に[elementId]
要素値またはデフォルトの要素値を取得すると考えていたので、このような単純なケースでコンパイルエラーが発生する可能性があるのではないでしょうか。