2013/4/7 Vicente J. Botet Escriba <
vicent...@wanadoo.fr>:
> Le 04/04/13 22:46, Daniel Krügler a écrit :
>
[..]
> While testing an expected<T> implementation I was expecting that the source
> of a move will not have an exception associated, but for what you say, I
> should be wrong, an the expected state should be undefined.
More precisely, for std::exception_ptr the state of the source of a
move is unspecified. You should be able to call every member function
that has a wide contract (i.e. that has no precondition of calling
it). I wonder why you find the precise state of a source of a move
important, since it actually is an object that you should have given
up interest in.
Note that the standard library has already wording special wording in
[res.on.arguments] p1 b3,
"If a function argument binds to an rvalue reference parameter, the
implementation may assume that this parameter is a unique reference to
this argument. [ Note: If the parameter is a generic parameter of the
form T&& and an lvalue of type A is bound, the argument binds to an
lvalue reference (14.8.2.1) and thus is not covered by the previous
sentence. —end note ] [ Note: If a program casts an lvalue to an
xvalue while passing that lvalue to a library function (e.g. by
calling the function with the argument move(x)), the program is
effectively asking that function to treat that lvalue as a temporary.
The implementation is free to optimize away aliasing checks which
might be needed if the argument was an lvalue. —end note ]"
that gives implementations special allowance for moveable objects.
Let me make clear, that I'm not strongly against adding more concrete
move semantics of std::exception_ptr to the library specification, I'm
only wondering how important that would be.
- Daniel