mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
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:
parent
0fb8ed38d7
commit
4d722623a6
1 changed files with 24 additions and 0 deletions
24
inc/thorvg.h
24
inc/thorvg.h
|
@ -1625,6 +1625,30 @@ public:
|
|||
_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
|
||||
|
|
Loading…
Add table
Reference in a new issue