Namespaces
Variants
Views
Actions

Talk:cpp/error/runtime error

From cppreference.com

Wasn't the const char* constructor added in C++11 (not the const std::string& one)? I think this goes for a bunch of the exceptions here on cppreference.com /estan.

You're right! Some fixing is in order. --Cubbi (talk) 15:27, 12 November 2015 (PST)

[edit] Inconsistency in explanation why std::string&& is not accepted

"Because copying std::runtime_error is not permitted to throw exceptions, this message is typically stored internally as a separately-allocated reference-counted string. This is also why there is no constructor taking std::string&&: it would have to copy the content anyway. "

-> Doesn't the const ref version also need to copy the string away? (BTW, the std::string&& overload could *move* the content away).

217.7.252.169 06:15, 28 February 2020 (PST)

For normal classes, const ref overload copies, rvalue ref overload moves. Here, rvalue ref overload can't move, so it makes no sense to provide one. --Cubbi (talk) 07:13, 28 February 2020 (PST)