[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: ‘zk::future<zk::get_result> {aka class std::future<zk::get_result>}’ has no member named ‘then’ #107

Open
zg9uagfv opened this issue Jul 1, 2019 · 3 comments

Comments

@zg9uagfv
Copy link
zg9uagfv commented Jul 1, 2019

Env:

ubuntu18.04
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

Code:

int main()
{
    // Start a ZK server running on localhost (not needed if you just want a client, but great for testing and
    // demonstration purposes).
    zk::server::server server(zk::server::configuration::make_minimal("zk-data", 2181));

    // zk::client::connect returns a future<zk::client>, which is delivered when the connection is established.
    auto client = zk::client::connect("zk://127.0.0.1:2181").get();

    // get_result has a zk::buffer and zk::stat.
    client.get("/foo/bar").then(print_thing<zk::get_result>);
    return 0x00;
}

Compile Command:
g++ --std=c++17 -I ~/github/zookeeper-cpp/src/ test.cpp

Compile Error:
test.cpp: In function ‘int main()’: test.cpp:37:28: error: ‘zk::future<zk::get_result> {aka class std::future<zk::get_result>}’ has no member named ‘then’ client.get("/foo/bar").then(print_thing<zk::get_result>);

thanks a lot!

@tgockel
Copy link
Owner
tgockel commented Jul 1, 2019

The then function comes from the proposed std::experimental::future::then, which is still not in C++17. I was hoping the C++ Standard would catch up to my documentation. In the future, there will be a workaround to set ZKPP_FUTURE_USE_STD_EXPERIMENTAL to 1. This requires two changes:

  1. When building the library, cmake -DZKPP_BUILD_SETTING_FUTURE=STD_EXPERIMENTAL ..
  2. When using it in your own project, #define ZKPP_FUTURE_USE_STD_EXPERIMENTAL 1

NOTE: This will not work unless you have <experimental/future> implemented by your Standard Library implementation, which I don't know of any implementation this is true in. boost::future has a then implementation, but I haven't added ZKPP_BUILD_SETTING_FUTURE=BOOST_THREAD equivalent (yet).

@tuxflo
Copy link
tuxflo commented Aug 4, 2021

Sorry for bumping this old issue, but I'm facing the same problem. I saw that PR #112 was merged, but I can't figure out on how to use the .then of boost, since it seems to expect more than one argument.
Is there a minimal working example anywhere?

@robmarano
Copy link

+1

Sorry for bumping this old issue, but I'm facing the same problem. I saw that PR #112 was merged, but I can't figure out on how to use the .then of boost, since it seems to expect more than one argument. Is there a minimal working example anywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants