It seems that there's a difference between () and = constructor (ctor) here.
1 2 3 4 5 6 7 8 9
#include <functional>
#include <future>
int addNumbers(int a, int b) {
return a + b;
}
int main(){
// std::packaged_task<int()> pt = std::bind(addNumbers, 1,2); //doesn't work, why?
std::packaged_task<int()> pt(std::bind(addNumbers, 1,2));
}
I thought since pt was initialized with the std::function object returned by std::bind (correct me if it's actually not), = here should invoke the ctor for that std::function object. Why the first one doesn't work?