我一直认为C++中的临时对象会被编译器自动视为const.但最近我经历了以下代码示例:
function_returning_object().some_non_const_method();
对C++编译器有效.它让我想知道 - 是C++ const中的临时对象吗?如果是,那么为什么编译器认为上面的代码是正确的?
c++ const temporary
c++ ×1
const ×1
temporary ×1