Add a generic cast function for resolutions.

This is used in the new tlist class.
This commit is contained in:
Mark de Wever 2010-05-02 12:14:04 +00:00
parent a069bc85e5
commit 9b19381964

View File

@ -70,6 +70,24 @@ typedef
boost::intrusive_ptr<const tresolution_definition_>
tresolution_definition_const_ptr;
/**
* Casts a tresolution_definition_const_ptr to another type.
*
* @tparam T The type to cast to, the non const version.
*
* @param ptr The pointer to cast.
*
* @returns A reference to type casted to.
*/
template<class T>
const T& cast(tresolution_definition_const_ptr ptr)
{
boost::intrusive_ptr<const T> conf =
boost::dynamic_pointer_cast<const T>(ptr);
assert(conf);
return *conf;
}
struct tcontrol_definition
: public reference_counted_object
{