ことなく値の変化を引き起こす::マップがマップは、STDでiterator->第二に割り当てる理由を私は理解していない参照
#include <typeinfo>
#include <map>
#include <iostream>
int main() {
std::map<int, int> lol;
lol[2] = 33;
auto it = lol.find(2);
it->second = 91; // This changes the map's value
std::cout << typeid(it->second).name(); // This just shows 'int', not a reference
std::cout << lol[2]; // 91
return 0;
}
に値を変更しませんit->second
ちょうどintでありリファレンスではない?
'Typeid'は、それが参照かどうかを教えません。 –
@JakeFreemanこちらのテクニックでも動作しませんhttps://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c – Dean
@Barry Indeed 、 ならない。それを編集するには遅すぎて、私はただそれを削除します。 –