Member functions on boost::variant?

6 Sep
2009
6 Sep
'09
8:30 a.m.
Is there a nice way of calling a member function on a boost::variant (where I know said member function is implemented by all the types in the variant)? Chris

6 Sep
6 Sep
9:08 a.m.
Is there a nice way of calling a member function on a boost::variant (where I know said member function is implemented by all the types in the variant)?
if the member function has signature: retval func(); then you can call it using the following visitor: // warning: untested struct call_func : static_visitor<retval> { template<class T> result_type operator()(T t) const { return t.func(); } }; You can also pass parameters to the visitor constructor, then forward them to the func().
5649
Age (days ago)
5649
Last active (days ago)
1 comments
2 participants
participants (2)
-
Christopher Jefferson
-
Igor R