Boost logo

Boost :

Subject: [boost] [optional][thread] Returning a future in an optional fails
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2013-06-14 15:24:32


I just hit this using VS2012/boost 1.54 beta.

    #include <boost/optional.hpp>
    #include <future>

    boost::optional< std::future<void> > top() { return std::async( []{ int
i=0; ++i; } ); }

    int main()
   {
      auto opt = top();
    }

Error:

1>E:\Projects\SDK\boost\boost\include\boost-1_54\boost/optional/optional.hpp(347):
error C2248: 'std::future<void>::future' : cannot access private member
declared in class 'std::future<void>'
1> C:\Program Files (x86)\Microsoft Visual Studio
11.0\VC\include\future(1238) : see declaration of
'std::future<void>::future'
1> C:\Program Files (x86)\Microsoft Visual Studio
11.0\VC\include\future(1200) : see declaration of 'std::future<void>'
1>
 E:\Projects\SDK\boost\boost\include\boost-1_54\boost/optional/optional.hpp(346)
: while compiling class template member function 'void
boost::optional_detail::optional_base<T>::construct(const std::future<void>
&)'
1> with
1> [
1> T=std::future<void>
1> ]
1>
 E:\Projects\SDK\boost\boost\include\boost-1_54\boost/optional/optional.hpp(231)
: see reference to function template instantiation 'void
boost::optional_detail::optional_base<T>::construct(const std::future<void>
&)' being compiled
1> with
1> [
1> T=std::future<void>
1> ]
1>
 E:\Projects\SDK\boost\boost\include\boost-1_54\boost/optional/optional.hpp(501)
: see reference to class template instantiation
'boost::optional_detail::optional_base<T>' being compiled
1> with
1> [
1> T=std::future<void>
1> ]
1>
 E:\Projects\Art_Of_Sequence\repos\aos-all\tool\aosdesigner\backend\test\workspace.cpp(30)
: see reference to class template instantiation 'boost::optional<T>' being
compiled
1> with
1> [
1> T=std::future<void>
1> ]

I also tried with http://coliru.stacked-crooked.com/ gcc4.8 (but I don't
know the boost version)
and got a similar error.

I first hit this with boost::future but it don't seem to be the problem as
it generate the same error.

My question is: does std/boost::future don't match the requirements to be
an optional value?
Or is this an error I should log?

Joel Lamotte


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk