Let\'s say I have a bunch of well-known values, like this (but const char *
is just an example, it could be more complicated):
const char *A = \"A\"
If you have C++11:
auto res = some_complicated_expression_with_ugly_return_type;
if (res == A
|| res == C
|| res == E
|| res == G) {
}
if not, you can still eliminate the type declaration by using a template function:
template
bool matches(T t) {
return t == A || t == C || t == E || t == G;
}
if (matches(some_complicated_expression_with_ugly_return_type)) {
}