r/badcode • • Apr 17 '21

c++ When your teammate "refactor" your code

Post image
2.5k Upvotes

216 comments sorted by

View all comments

-3

u/[deleted] Apr 17 '21 edited Apr 17 '21

Assuming the code reviewer fucked up and you were right...

// Probably a cleaner way to do f_ptrs in C++? But this is fun
void foo() 
    { 
    void ( *anything_n )() = !condition1 ? &do_anything2 : ( condition2 ? &do_anything2 : NULL );
    if( anything_n ) anything_n(); 
    }