[test][distance] add missing typename
[distance] remove inner template parameter that shadows global
template parameter; qualify template method call with template keyword;
fix return type of variant visitors;