api: introduce cast() template method.

The cast() method is a utility function used to
cast a 'Paint/Fill' to type 'T'.

This would help users to write code optimal.

@API Additions:
template<typename T> std::unique_ptr<T> cast(Paint* paint)
template<typename T> std::unique_ptr<T> cast(Fill* fill)
This commit is contained in:
Hermet Park 2023-05-12 17:08:32 +09:00 committed by Hermet Park
parent 0fb8ed38d7
commit 4d722623a6

View file

@ -1625,6 +1625,30 @@ public:
_TVG_DECLARE_PRIVATE(Accessor); _TVG_DECLARE_PRIVATE(Accessor);
}; };
/**
* @brief The cast() function is a utility function used to cast a 'Paint' to type 'T'.
*
* @BETA_API
*/
template<typename T>
std::unique_ptr<T> cast(Paint* paint)
{
return std::unique_ptr<T>(static_cast<T*>(paint));
}
/**
* @brief The cast() function is a utility function used to cast a 'Fill' to type 'T'.
*
* @BETA_API
*/
template<typename T>
std::unique_ptr<T> cast(Fill* fill)
{
return std::unique_ptr<T>(static_cast<T*>(fill));
}
/** @}*/ /** @}*/
} //namespace } //namespace