Skip to content

Commit

Permalink
Fix _CHOOSE to use the copies instead of double execution of side-e…
Browse files Browse the repository at this point in the history
…ffects (issue reported by tromp at bitcointalk.org)
  • Loading branch information
shelby3 committed Dec 1, 2015
1 parent bd4ea5b commit b817c6c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmacros/effectless.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Generic min and max without double execution of side-effects:
http://stackoverflow.com/questions/3437404/min-and-max-in-c
*/

#define _CHOOSE(boolop, a, b, uid) \
({ \
decltype(a) _a_ ## uid = (a); \
decltype(b) _b_ ## uid = (b); \
(a) boolop (b) ? (a) : (b); \
#define _CHOOSE(boolop, a, b, uid) \
({ \
decltype(a) _a_ ## uid = (a); \
decltype(b) _b_ ## uid = (b); \
(_a_ ## uid) boolop (_b_ ## uid) ? (_a_ ## uid) : (_b_ ## uid); \
})
#undef MIN
#undef MAX
Expand Down

0 comments on commit b817c6c

Please sign in to comment.