Title
promise and packaged_task missing constructors needed for uses-allocator construction
Status
lewg
Section
[futures.promise][futures.task]
Submitter
Jonathan Wakely

Created on 2011-11-01.00:00:00 last changed 59 months ago

Messages

Date: 2019-06-03.09:53:27

[ This wording is relative to N4810. ]

  1. Add to [futures.promise], class template promise synopsis, as indicated:

    namespace std {
      template <class R>
      class promise {
      public:
        promise();
        template <class Allocator>
          promise(allocator_arg_t, const Allocator& a);
        template <class Allocator>
          promise(allocator_arg_t, const Allocator& a, promise&& rhs) noexcept;
        promise(promise&& rhs) noexcept;
        promise(const promise& rhs) = delete;
        ~promise();
        […]
      };
      […]
    }
    
  2. Change [futures.promise] as indicated:

    promise(promise&& rhs) noexcept;
    template <class Allocator>
      promise(allocator_arg_t, const Allocator& a, promise&& rhs) noexcept;
    

    -5- Effects: constructs a new promise object and transfers ownership of the shared state of rhs (if any) to the newly-constructed object.

    -6- Postcondition: rhs has no shared state.

    -?- [Note: a is not used — end note]

Date: 2019-06-03.00:00:00

[ 2019-06-03 Jonathan Wakely provides updated wording ]

Jonathan updates wording post-2976 and observes that this resolution conflicts with 3003.

Previous resolution [SUPERSEDED]:

This wording is relative to the FDIS.
  1. Add to [futures.promise], class template promise synopsis, as indicated:

    namespace std {
      template <class R>
      class promise {
      public:
        promise();
        template <class Allocator>
        promise(allocator_arg_t, const Allocator& a);
        template <class Allocator>
        promise(allocator_arg_t, const Allocator& a, promise&& rhs) noexcept;
        promise(promise&& rhs) noexcept;
        promise(const promise& rhs) = delete;
        ~promise();	
        […]
      };
      […]
    }
    
  2. Change [futures.promise] as indicated:

    promise(promise&& rhs) noexcept;
    template <class Allocator>
    promise(allocator_arg_t, const Allocator& a, promise&& rhs) noexcept;
    

    -5- Effects: constructs a new promise object and transfers ownership of the shared state of rhs (if any) to the newly-constructed object.

    -6- Postcondition: rhs has no shared state.

    -?- [Note: a is not used — end note]

  3. Add to [futures.task], class template packaged_task synopsis, as indicated:

    namespace std {
      template<class> class packaged_task; // undefined
    
      template<class R, class... ArgTypes>
      class packaged_task<R(ArgTypes...)> {
      public:
        // construction and destruction
        packaged_task() noexcept;
        template <class Allocator>
          packaged_task(allocator_arg_t, const Allocator& a) noexcept;
        template <class F>
          explicit packaged_task(F&& f);
        template <class F, class Allocator>
          explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
        ~packaged_task();
    	
        // no copy
        packaged_task(const packaged_task&) = delete;
        template<class Allocator>
          packaged_task(allocator_arg_t, const Allocator& a, const packaged_task&) = delete;
        packaged_task& operator=(const packaged_task&) = delete;
        
        // move support
        packaged_task(packaged_task&& rhs) noexcept;
        template <class Allocator>
          packaged_task(allocator_arg_t, const Allocator& a, packaged_task&& rhs) noexcept;
        packaged_task& operator=(packaged_task&& rhs) noexcept;
        void swap(packaged_task& other) noexcept;
        […]
      };
      […]
    }
    
  4. Change [futures.task.members] as indicated:

    packaged_task() noexcept;
    template <class Allocator>
      packaged_task(allocator_arg_t, const Allocator& a) noexcept;
    

    -1- Effects: constructs a packaged_task object with no shared state and no stored task.

    -?- [Note: a is not used — end note]

    […]

    packaged_task(packaged_task&& rhs) noexcept;
    template <class Allocator>
      packaged_task(allocator_arg_t, const Allocator& a, packaged_task&& rhs) noexcept;
    

    -5- Effects: constructs a new packaged_task object and transfers ownership of rhs's shared state to *this, leaving rhs with no shared state. Moves the stored task from rhs to *this.

    -6- Postcondition: rhs has no shared state.

    -?- [Note: a is not used — end note]

Date: 2016-08-06.21:12:20

[ 2016-08 Chicago ]

Fri PM: Send to LEWG - and this also applies to function in LFTS.

Date: 2014-02-20.00:00:00

[ 2014-02-20 Re-open Deferred issues as Priority 4 ]

Date: 2013-09-26.11:12:18

[ 2013-09 Chicago ]

Move to deferred.

This issue has much in common with similar problems with std::function that are being addressed by the polymorphic allocators proposal currently under evaluation in LEWG. Defer further discussion on this topic until the final outcome of that paper and its proposed resolution is known.

Date: 2013-03-06.00:00:00

[ 2013-03-06 ]

Jonathan suggests to make the new constructors non-explicit and makes some representational improvements.

Date: 2012-11-02.22:48:46

[ 2012, Portland ]

This is an allocator issue, and should be dealt with directly by LWG.

Date: 2011-11-01.00:00:00

This example is ill-formed according to C++11 because uses_allocator<promise<R>, A>::value is true, but is_constructible<promise<R>, A, promise<R>&&>::value is false. Similarly for packaged_task.

#include <future>
#include <memory>
#include <tuple>

using namespace std;

typedef packaged_task<void()> task;
typedef promise<void> prom;
allocator<task> a;

tuple<task, prom> t1{ allocator_arg, a };
tuple<task, prom> t2{ allocator_arg, a, task{}, prom{} };
History
Date User Action Args
2019-06-03 09:53:27adminsetmessages: + msg10412
2016-08-06 21:12:20adminsetmessages: + msg8442
2016-08-06 21:12:20adminsetstatus: open -> lewg
2014-02-20 14:24:46adminsetmessages: + msg6881
2014-02-20 14:24:46adminsetstatus: deferred -> open
2013-09-26 11:12:18adminsetmessages: + msg6624
2013-09-26 11:12:18adminsetstatus: new -> deferred
2013-03-17 21:47:11adminsetmessages: + msg6397
2012-11-02 22:48:46adminsetmessages: + msg6236
2011-11-27 19:46:43adminsetmessages: + msg5920
2011-11-01 00:00:00admincreate