【发布时间】:2014-02-10 16:30:51
【问题描述】:
std::map 的 operator[] 函数返回一个左值引用,即使地图本身是一个右值。
T& operator[]( const Key& key );
这会导致未定义的行为用法,例如this one。为什么没有像下面这样的左值和右值重载?是否有任何其他地图实现使用此类重载?
T& operator[]( const Key& key ) &;
T operator[]( const Key& key ) &&;
【问题讨论】: