Skip to content

Instantly share code, notes, and snippets.

#define CFSetForeach(type,element,set) \
for (typeof(type) element, \
*_foreach_set = (typeof(type)*)set, \
*_foreach_count = (typeof(type)*)(intptr_t)CFSetGetCount((CFSetRef)_foreach_set), \
*_foreach_cache[(intptr_t)_foreach_count + 1], \
*_foreach_index = (CFSetGetValues((CFSetRef)_foreach_set,(const void**)_foreach_cache), (typeof(type)*)(intptr_t)0); \
element = ((typeof(type)*)_foreach_cache)[(intptr_t)_foreach_index], ((intptr_t)_foreach_index < (intptr_t)_foreach_count); \
_foreach_index = (typeof(type)*)((intptr_t)_foreach_index + 1))