Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define foreach__(a, index_name, element_name, array) if(0) finished##a: ; else for(auto element_name = &(array).elements[0];;) if(1) goto body##a; else while(1) if(1) goto finished##a; else body##a: for(int index_name = 0; index_name < (array).count && (bool)(element_name = &(array)[index_name]); index_name++)
- #define foreach_(a, index_name, element_name, array) foreach__(a, index_name, element_name, array)
- #define foreach(index_name, element_name, array) foreach_(__LINE__, index_name, element_name, array)
- #define foreach_raw__(a, index_name, element_name, array) if(0) finished##a: ; else for(auto element_name = (array).elements[0];;) if(1) goto body##a; else while(1) if(1) goto finished##a; else body##a: for(int index_name = 0; index_name < (array).count && (void*)&(element_name = (array)[index_name]); index_name++)
- #define foreach_raw_(a, index_name, element_name, array) foreach_raw__(a, index_name, element_name, array)
- #define foreach_raw(index_name, element_name, array) foreach_raw_(__LINE__, index_name, element_name, array)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement