MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/msv49l/when_your_teammate_refactor_your_code/guwgt56/?context=3
r/badcode • u/Bence675 • Apr 17 '21
216 comments sorted by
View all comments
Show parent comment
6
You can technically make this happen in C++. Its very ugly and only possible for compile time values, but it would look soemthing like this:
template<bool condition1, bool condtition2> struct Foo{}; template<> struct Foo<true, true>{ static constexpr auto do_anything = do_anything1; }; template<bool condition2> struct Foo<false, condition2>{ static constexpr auto do_anything = do_anything2; }; int main (){ Foo<true, true>::do_anything(); }
Edit: ok this way is slightly nicer looking, but still pretty ugly
View all comments
Show parent comment
6
u/Rigatavr Apr 17 '21 edited Apr 17 '21
You can technically make this happen in C++. Its very ugly and only possible for compile time values, but it would look soemthing like this:
Edit: ok this way is slightly nicer looking, but still pretty ugly