It all depends. I can only think of one situation where a ternary operator undeniably improves readability and even performance (see bottom of this answer). But generally, using the ternary isn't going to improve readability/maintainability of your code. If you use it occasionally, and only for simple assignments then it's OK. not good, just acceptable IMO. Others are, of course, free to disgree with me on that.
Ternaries are expressions, so they should only be used as such (part of an assignment, for example). If you start using ternaries as statements, then you're in trouble. Ternaries are not statements, using them as such is like using a spoon as a screwdriver. Silly.
On the whole, though: it's a matter of taste as long as you don't overdo it. Once you start nesting ternaries, using them with pointers to pointers, or as statements, it's a matter of lunacy.
But to be honest: when in doubt: don't use the ternary operator. It saves you 1 line of code and doesn't improve performance. Take your example:
if (a > b) result = x;
else result = y;
//vs:
result = a > b ? x : y;
if result
is the return value of a function, you could even write:
if (a > b) return x;
return y;
Even though I now have 2 return statements, I still find this code easier to read than:
result = a > b ? x : y;
//or
return a > b ? x : y;
That one use-case where a ternary is the best option is this:
const int two_options = some_arg ? 23 : 1;
This enables you to define + initialize a const
within a function's scope, depending on a condition, without the overhead of an additional function call (const int two_opts = arg_func(some_arg);
, where the function contains the if-else
)