Boost logo

Boost Users :

Subject: [Boost-users] [thread] Using lambda with unique_future
From: Christian Henning (chhenning_at_[hidden])
Date: 2013-03-05 15:16:51


Hi all,

I'm toying around with futures and I'm stumbling with the Visual
Studio 2010 compiler.

The following doesn't compile:

#include <iostream>

#include <boost/thread/future.hpp>

int main()
{
    boost::unique_future<int> the_answer = boost::async( [] () ->int {
return 42; } );

    std::cout << the_answer.get() << std::endl;

    return 0;
}

the error is:

1>c:\gil_contributions\sdl_test\async_test.cpp(9): error C2440:
'initializing' : cannot convert from 'boost::unique_future<R>' to
'boost::unique_future<R>'
1> with
1> [
1> R=void
1> ]
1> and
1> [
1> R=int
1> ]
1> No constructor could take the source type, or constructor
overload resolution was ambiguous

clang works just fine:
http://liveworkspace.org/code/1gOYwa$2

Is this a compiler error or am I doing something wrong?

Thanks,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net