This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.

### 2098. Minor Inconsistency between `promise::set_value` and `promise::set_value_at_thread_exit`

Section: 33.10.6 [futures.promise] Status: C++14 Submitter: Pete Becker Opened: 2011-11-14 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [futures.promise].

View all other issues in [futures.promise].

View all issues with C++14 status.

Discussion:

33.10.6 [futures.promise]/16 says that `promise::set_value(const R&)` throws any exceptions thrown by `R`'s copy constructor, and that `promise_set_value(R&&)` throws any exceptions thrown by `R`'s move constructor.

33.10.6 [futures.promise]/22 is the Throws: clause for `promise::set_value_at_thread_exit`. It has no corresponding requirements, only that these functions throw "`future_error` if an error condition occurs."

Daniel suggests wording to fix this: The approach is a bit more ambitious and also attempts to fix wording glitches of 33.10.6 [futures.promise]/16, because it would be beyond acceptable efforts of implementations to determine whether a constructor call of a user-defined type will indeed call a copy constructor or move constructor (in the first case it might be a template constructor, in the second case it might also be a copy-constructor, if the type has no move constructor).

[2012, Portland: move to Review]

Moved to Review by the concurrency working group, with no further comments.

[2013-04-20, Bristol]

Accepted for the working paper

Proposed resolution:

This wording is relative to the FDIS.

1. Change 33.10.6 [futures.promise]/16 as indicated:

   >     void promise::set_value(const R& r);
   >     void promise::set_value(R&& r);
   >     void promise<R&>::set_value(R& r);
   >     void promise<void>::set_value();

   > > […]

   > > -16- Throws:
   > > - `future_error` if its shared state already has a stored value or exception, or
   > > - for the first version, any exception thrown by the copy constructor of constructor selected to copy an object of `R`, or
   > > - for the second version, any exception thrown by the move constructor of constructor selected to move an object of `R`.

2. Change 33.10.6 [futures.promise]/22 as indicated:

   >     void promise::set_value_at_thread_exit(const R& r);
   >     void promise::set_value_at_thread_exit(R&& r);
   >     void promise<R&>::set_value_at_thread_exit(R& r);
   >     void promise<void>::set_value_at_thread_exit();

   > > […]

   > > -16- Throws: `future_error` if an error condition occurs.
   > > - `future_error` if its shared state already has a stored value or exception, or
   > > - for the first version, any exception thrown by the constructor selected to copy an object of `R`, or
   > > - for the second version, any exception thrown by the constructor selected to move an object of `R`.