Date
2009-05-13.00:00:00
Message id
850

Content

The naming of std::copy_exception misleads almost everyone (experts included!) to think that it is the function that copies an exception_ptr:

exception_ptr p1 = current_exception();
exception_ptr p2 = copy_exception( p1 );

But this is not at all what it does. The above actually creates an exception_ptr p2 that contains a copy of p1, not of the exception to which p1 refers!

This is, of course, all my fault; in my defence, I used copy_exception because I was unable to think of a better name.

But I believe that, based on what we've seen so far, any other name would be better.

Therefore, I propose copy_exception to be renamed to create_exception:

template<class E> exception_ptr create_exception(E e);

with the following explanatory paragraph after it:

Creates an exception_ptr that refers to a copy of e.