$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] Member functions on boost::variant?
From: Igor R (boost.lists_at_[hidden])
Date: 2009-09-06 05:08:33
> 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().