@class NSArray;
@interface NSMutableDictionary
- (id)objectForKeyedSubscript:(id)key;
- (void)setObject:(id)object forKeyedSubscript:(id)key; @end
template<typename T, typename U, typename O>
void test_dictionary_subscripts(T base, U key, O obj) {
base[key] = obj; obj = base[key];
}
template void test_dictionary_subscripts(NSMutableDictionary*, id, NSArray *ns);
template void test_dictionary_subscripts(NSMutableDictionary*, NSArray *ns, id);
template void test_dictionary_subscripts(NSMutableDictionary*, int, id);
template void test_dictionary_subscripts(NSMutableDictionary*, id, int);
@interface NSMutableArray
- (id)objectAtIndexedSubscript:(int)index;
- (void)setObject:(id)object atIndexedSubscript:(int)index;
@end
template<typename T, typename U, typename O>
void test_array_subscripts(T base, U index, O obj) {
base[index] = obj; obj = base[index]; }
template void test_array_subscripts(NSMutableArray *, int, id);
template void test_array_subscripts(NSMutableArray *, short, id);
enum E { e };
template void test_array_subscripts(NSMutableArray *, E, id);
template void test_array_subscripts(NSMutableArray *, double, id);
template<typename T>
struct ConvertibleTo {
operator T();
};
template<typename T>
struct ExplicitlyConvertibleTo {
explicit operator T();
};
template<typename T> ConvertibleTo<T> makeConvertible();
struct X {
ConvertibleTo<id> x;
ConvertibleTo<id> get();
};
NSMutableArray *test_array_convertibility(ConvertibleTo<NSMutableArray*> toArray,
ConvertibleTo<id> toId,
ConvertibleTo<int (^)(int)> toBlock,
ConvertibleTo<int> toInt,
ExplicitlyConvertibleTo<NSMutableArray *> toArrayExplicit) {
id array;
array[1] = toArray;
array[4] = array[1];
toArrayExplicit[2] = toId;
return array[toInt];
}
id test_dict_convertibility(ConvertibleTo<NSMutableDictionary*> toDict,
ConvertibleTo<id> toId,
ConvertibleTo<int (^)(int)> toBlock,
ConvertibleTo<int> toInt,
ExplicitlyConvertibleTo<NSMutableDictionary *> toDictExplicit) {
NSMutableDictionary *Dict;
id Id;
Dict[toId] = toBlock;
Dict[toBlock] = toBlock;
Dict[toBlock] = Dict[toId] = Dict[toBlock];
Id = toDictExplicit[toId] = Id;
return Dict[toBlock];
}
template<typename ...Args>
void test_bad_variadic_array_subscripting(Args ...args) {
id arr1;
arr1[3] = args; }
template<typename ...Args>
void test_variadic_array_subscripting(Args ...args) {
id arr[] = {args[3]...}; }
template void test_variadic_array_subscripting(id arg1, NSMutableArray* arg2, id arg3);
@class Key;
template<typename Index, typename ...Args>
void test_variadic_dictionary_subscripting(Index I, Args ...args) {
id arr[] = {args[I]...}; }
template void test_variadic_dictionary_subscripting(Key *key, id arg1, NSMutableDictionary* arg2, id arg3);
template<int N>
id get(NSMutableArray *array) {
return array[N]; }
struct WeirdIndex {
operator int(); operator id(); };
id FUNC(WeirdIndex w) {
NSMutableArray *array;
return array[w]; }