[Bug libstdc++/56492] New: std::packaged_task requires CopyConstructible stored task

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 1 10:44:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56492

             Bug #: 56492
           Summary: std::packaged_task requires CopyConstructible stored
                    task
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


This is rejected because std::packaged_task uses std::function internally and
std::function requires a CopyConstructible target object:

#include <future>

struct S
{
  S() = default;
  S(S&&) = default;
  void operator()() { }
};

std::packaged_task<void ()> pt{ S{} };


It's not necessary to use std::function, the _Task_state type could hold the
stored task directly, which would allow it to be move constructed.



More information about the Gcc-bugs mailing list