Who is responsible for the shared state of futures and promises

久未见 提交于 2019-12-05 05:16:14

When the std::future (or std::promise) is destroyed, it releases its shared state.

This rule states that when an asynchronous return object or an asynchronous provider is said to release its shared state, it gives up its reference to the shared state.

If that reference was the last one, the shared state is destroyed.

So yes, shared state seems to be reference counted and no, your code example does not produce UB since prom still holds a reference to the shared state.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!