https://bugs.llvm.org/show_bug.cgi?id=41032

            Bug ID: 41032
           Summary: parameter passed to std::packaged_task byref stays
                    wrapped with std::reference_wrapper
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: kirsha...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

auto task = std::packaged_task<int(const std::vector<int>&)>{
[] (const auto& vec) {
    // clang pass into the method std::reference_wrapper
    // correct behavior should be to unwrap it 
    return std::accumulate(vec.get().begin(), vec.get().end(), 0);
}};

// Code above works only because of the call to 'get' to retrieve the content
of the std::reference_wrapper

// Call the task with some std::vector<int> named vec:
std::thread t = std::thread(std::move(task), std::cref(vec));

Full code:
http://coliru.stacked-crooked.com/a/cc3b2c44ef5d9834

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to