Properly detect the end of the "false part" of ternary operators when it contains '>'

Hi,

As noticed by PKEuS, my fix for ticket #5625 causes a regression as it does not detect the end of the "false part" of ternary operator expressions such as "a ? b : c > d". This patch fixes it by only considering '>' as a terminator when the ternary operator is in some template parameter. Thanks to consider merging.

Cheers,
  Simon