[C++] Container for any type

Started by
9 comments, last by kloffy 18 years, 1 month ago
I've got another short question: Is this a good way of implementing an unsafe cast for CAnyTypeWrapper?

template<typename TType> TType unsafe_cast(CAnyTypeWrapper &obj) { 	return *((TType*)((CAnyType<TType>*)obj.object->get())); }

To allow access to object you'd have to make it a friend function of CAnyTypeWrapper. A call would look like that:
CAnyTypeWrapper any(5);int i = unsafe_cast<int>(any);

This topic is closed to new replies.

Advertisement