Add const char* constructors for exception classes in <stdexcept>

Oleg Endo oleg.endo@t-online.de
Thu Dec 19 00:11:00 GMT 2013


Hello,

When writing code such as
...
  throw std::logic_error ("cold coffee");
...
currently the construction of std::string happens in the code that
throws the exception, which results in code bloat.  Implementing the
const char* constructors as defined by C++11 fixes the issue.
I'm not sure whether the #if __cplusplus >= 201103L checks are required.
C++98 code could also benefit from the overloads.

Tested with 'make all' and 'make install', writing a hello world and
checking the asm output.

Cheers,
Oleg

libstdc++-v3/ChangeLog:

	* include/std/stdexcept (logic_error, domain_error, 
	invalid_argument, length_error, out_of_range, runtime_error, 
	range_error, overflow_error, underflow_error): Declare const 
	char* constructors.
	* src/c++98/stdexcept.cc (logic_error, domain_error, 
	invalid_argument, length_error, out_of_range, runtime_error, 
	range_error, overflow_error, underflow_error): Implement them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stdexcept_constchar.patch
Type: text/x-patch
Size: 5350 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20131219/166d50f4/attachment.bin>


More information about the Libstdc++ mailing list