I found this https://gist.github.com/2945472 but I need an implementation that does not depend on c++11. I tried my hand at converting it to use only boost, but I\'m having
Try to use extendable any https://sourceforge.net/projects/extendableany/?source=directory.
struct f_method
{
typedef void (boost::mpl::_1::* signature) () const;
template
struct wrapper
: public T
{
void f() const
{
return this->call(f_method());
}
};
struct implementation
{
void operator() (int i) const
{
std::cout << "fa(" << i << ")" << std::endl;
}
void operator() (abc) const
{
std::cout << "fb(abc())" << std::endl;
}
template
void operator() (const T& t) const
{
std::cout << "Errr" << std::endl;
}
};
};
typedef xany > any;
int main() {
std::vector xs;
xs.push_back(1);
xs.push_back(abc());
xs.push_back(1.5);
for (auto it=xs.begin(); it!=xs.end(); ++it)
(*it).f();
}