| 48 | |
| 49 | template <class T, class... Args> |
| 50 | static T* create(Args&&... args) { |
| 51 | static_assert(std::is_base_of<Object, T>::value, "T must be a subclass of Object"); |
| 52 | T* item = new T(std::forward<Args>(args)...); |
| 53 | if (item && item->init()) { |
| 54 | item->autorelease(); |
| 55 | } else if (item->getRefCount() == 0) { |
| 56 | delete item; |
| 57 | item = nullptr; |
| 58 | } else { |
| 59 | item = nullptr; |
| 60 | } |
| 61 | return item; |
| 62 | } |
| 63 | |
| 64 | template <class T, class... Args> |
| 65 | static T* createNotNull(Args&&... args) { |
nothing calls this directly
no test coverage detected