Hi All,
Andrey Semashev Vicente J. Botet Escriba wrote: Hi, I've started to use C++11 lambda functions with Boost.Thread. The following works with clang-3.2 boost::future<int> f1 = boost::async( []() -> int {return 123;} ); But it fails with gcc-4.6.2, 4.7.2 and 4.8.0 ../example/lambda_future.cpp:25:91: erreur: conversion from
‘boost::future<void>’ to non-scalar type ‘boost::future<int>’ requested
boost::future<int> f1 = boost::async( []() -> int {return 123;} ); The current implementation of boost::async uses boost::result_of to get
the result type of the callable parameter. Is this a know bug on boost::result_of or gcc compiler? I think this is because result_of is based on decltype for clang and TR1
protocol for gcc. This is because gcc doesn't support N3276. 4.8.0 release
notes state that it is supported but I saw someone on the list found some
bug
in it so the support is incomplete for now. For what it's worth, there's a patch in trac[1] which would allow the
previous to compile without requiring a full decltype implementation and
without causing errors when using tr1::result_of would succeed.
The patch was created after some discussion[2], but I haven't continued to
push for its acceptance -- work happens. Some may find it useful, however.
Thanks,
Nate
[1] https://svn.boost.org/trac/boost/ticket/7753
[2]
http://boost.2283326.n4.nabble.com/Range-amp-c-0x-Lambdas-Can-this-be-done-t...