mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 02:46:00 +00:00
Add a generic cast function for resolutions.
This is used in the new tlist class.
This commit is contained in:
parent
a069bc85e5
commit
9b19381964
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user