Using boost::any
is very useful but it's very depressing that it has no getter, and always we have to use any_cast
for casting it to type we want. But why it has no such thing? In my opinion the one bellow can be useful member. Is there some bad things I can't see?
template <class T>
void get(T * handle)
{
*handle = boost::any_cast<T>(*this);
}
Edit:
The only bad thing I see, that this getter requires to have assignment operator.