@@ -33,7 +33,7 @@ ScalarType deduceType(NSNumber *number);
33
33
* @return The value converted to type T.
34
34
*/
35
35
template <typename T>
36
- T extractValue (NSNumber *number) {
36
+ T toType (NSNumber *number) {
37
37
ET_CHECK_MSG (!(isFloatingType (deduceType (number)) &&
38
38
isIntegralType (CppTypeToScalarType<T>::value, true )),
39
39
" Cannot convert floating point to integral type" );
@@ -87,7 +87,7 @@ std::vector<T> toVector(NSArray<NSNumber *> *array) {
87
87
std::vector<T> vector;
88
88
vector.reserve (array.count );
89
89
for (NSNumber *number in array) {
90
- vector.push_back (extractValue <T>(number));
90
+ vector.push_back (toType <T>(number));
91
91
}
92
92
return vector;
93
93
}
@@ -108,10 +108,11 @@ constexpr bool isNSNumberWrapable =
108
108
* @return An NSArray populated with NSNumber objects representing the container's items.
109
109
*/
110
110
template <typename Container>
111
+ NS_RETURNS_RETAINED
111
112
NSArray <NSNumber *> *toNSArray (const Container &container) {
112
113
static_assert (isNSNumberWrapable<typename Container::value_type>, " Invalid container value type" );
113
114
const NSUInteger count = std::distance (std::begin (container), std::end (container));
114
- NSMutableArray <NSNumber *> *array = [NSMutableArray arrayWithCapacity : count];
115
+ NSMutableArray <NSNumber *> *array = [[ NSMutableArray alloc ] initWithCapacity : count];
115
116
for (const auto &item : container) {
116
117
[array addObject: @(item)];
117
118
}
0 commit comments