- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried to create a tbb::flow::function_node on a move-only type, e.g.
#include <tbb/flow_graph.h> class MyType { public: MyType() = default; MyType(const MyType&) = delete; MyType& operator=(const MyType&) = delete; MyType(MyType&&) = default; MyType& operator=(MyType&&) = default; ~MyType() = default; }; int main() { tbb::flow::graph g; tbb::flow::function_node<int, int> { g, 1, MyType{} }; }
However, this does not work, because function_body_leaf stores a copy of the body. Why is this necessary? Is it possible, to use move-only types with tbb::flow?
Best regards,
Florian
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Florian,
There are several features of the body of function_node which disallow move-only bodies.
- After a graph has executed, one can fetch the current state of the body to examine it. A move-only body would leave the function_node without a body to execute.
- copy-construction
- re-initialization of the node body with a copy made at construction time.
Regards,
Chris
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Florian,
There are several features of the body of function_node which disallow move-only bodies.
- After a graph has executed, one can fetch the current state of the body to examine it. A move-only body would leave the function_node without a body to execute.
- copy-construction
- re-initialization of the node body with a copy made at construction time.
Regards,
Chris
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page