(Follow-up of Overload ternary ?: operator, or change to if{}else{} in included files.)
Context
Research project here. In my C++ library, I am including C files using #include "aprogram.c"
which I execute symbolically by overloading (almost) all operators.
I have to be able to detect (condition) ? this : that
and extract condition
, this
and that
for usage in my symbolic execution library, for the following cases:
(a >= 0) ? a : -a
(a >= b) ? a : b
Conceptual question
Because I cannot overload the ternary ?: operator in C++, and it only has to work for the above cases, can't I 'overload' them by using macros somewhat like:
#define TO_NEG(a) ((a >= 0) ? a : -a)
#define MAX(a,b) ((a >= b) ? a : b)
and implement TO_NEG(a) and MAX(a,b)?
Edit: Clarification
With this, I want to achieve that my library
- detects ?: in both cases
- converts it to TO_NEG or MAX
- uses new code I wrote for TO_NEG and MAX