You can combine C++ templates and Objective-C lightweight generics if you use enough angle brackets. This is similar to as? in Swift (except it doesn’t check the array contents).