Created on 2009-05-13.00:00:00 last changed 162 months ago
Proposed resolution:
Change [support.exception]/1, header <exception> synopsis as indicated:
exception_ptr current_exception(); void rethrow_exception [[noreturn]] (exception_ptr p); template<class E> exception_ptrcopy_exceptionmake_exception_ptr(E e);
Change [propagation]:
template<class E> exception_ptrcopy_exceptionmake_exception_ptr(E e);-11- Effects: Creates an exception_ptr that refers to a copy of e, as if
try { throw e; } catch(...) { return current_exception(); }...
Change [futures.promise]/7 as indicated:
Effects: if the associated state of *this is not ready, stores an exception object of type future_error with an error code of broken_promise as if by this->set_exception(
copy_exceptionmake_exception_ptr( future_error(future_errc::broken_promise)). Destroys ...
[ 2009-11-16 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
[ 2009-11-16 Peter adopts wording supplied by Daniel. ]
[ 2009-11-16 Jonathan Wakely adds: ]
GCC 4.4 shipped with copy_exception but we could certainly keep that symbol in the library (but not the headers) so it can still be found by any apps foolishly relying on the experimental C++0x mode being ABI stable.
[ 2009 Santa Cruz: ]
Move to Review for the time being. The subgroup thinks this is a good idea, but doesn't want to break compatibility unnecessarily if someone is already shipping this. Let's talk to Benjamin and PJP tomorrow to make sure neither objects.
[ 2009-06-02 Thomas J. Gritzan adds: ]
To avoid surprises and unwanted recursion, how about making a call to std::make_exception_ptr with an exception_ptr illegal?
It might work like this:
template<class E> exception_ptr make_exception_ptr(E e); template<> exception_ptr make_exception_ptr<exception_ptr>(exception_ptr e) = delete;
[ 2009-05-13 Peter adds: ]
make_exception_ptr works for me.
[ 2009-05-13 Daniel adds: ]
What about
make_exception_ptrin similarity to make_pair and make_tuple, make_error_code and make_error_condition, or make_shared? Or, if a stronger symmetry to current_exception is preferred:
make_exceptionWe have not a single create_* function in the library, it was always make_* used.
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg858 |
2010-10-21 18:28:33 | admin | set | messages: + msg857 |
2010-10-21 18:28:33 | admin | set | messages: + msg856 |
2010-10-21 18:28:33 | admin | set | messages: + msg855 |
2010-10-21 18:28:33 | admin | set | messages: + msg854 |
2010-10-21 18:28:33 | admin | set | messages: + msg853 |
2010-10-21 18:28:33 | admin | set | messages: + msg852 |
2010-10-21 18:28:33 | admin | set | messages: + msg851 |
2009-05-13 00:00:00 | admin | create |