Fix ticket #5605 (take 3)

Hi,

This PR is a follow-up to https://github.com/danmar/cppcheck/pull/291, that unfortunately caused a regression (see ticket #5759): we need to be a bit more clever at handling template parameters if they contain pointers to class members.

Thanks to consider merging.

Cheers,
  Simon