Boost cannot find future::then from demo
Asked Answered
S

1

8

I wanted to try boost future then, I have boost 1.55 installed and included in make file and I wanted to try official demo

#define BOOST_THREAD_PROVIDES_FUTURE

#include <boost/thread/future.hpp>

using namespace boost;

int main()
{
  future<int> f1 = async([]() { return 123; });
  future<int> f2 = f1.then([](future<int> f) { return f.get();} );// here .get() won't block });
} 

but I always get error during compilation

error: ‘class boost::future<int>’ has no member named ‘then’

When I commented line with f2 it compiles.

Solander answered 30/4, 2014 at 2:23 Comment(0)
H
11

You should define

#define BOOST_THREAD_VERSION 4

or

#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
Heavensent answered 30/4, 2014 at 3:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.