根据cppreference.com,其中一个std::runtime_error有以下签名:
std::runtime_error
explicit runtime_error( const std::string& what_arg );
但是(我假设)新构造的异常对象需要保存该std::string参数的副本.那么为什么const ref(而不是值)给出的论证呢?
std::string
我的假设错了吗?
c++ memory-management reference exception
c++ ×1
exception ×1
memory-management ×1
reference ×1