I'm building a simple text analyzer. I have the following code:
template<typename FwdIt0, typename FwdIt1, typename Comp, typename Num>
Num SmartAnalyzer::count_intersection(FwdIt0 beg0, FwdIt0 end0, FwdIt1 beg1, FwdIt1 end1, Comp less, Num n)
{
while (beg0 != end0 && beg1 != end1)
{
if (less(*beg0, *beg1)) ++beg0;
else if (less(*beg1, *beg0)) ++beg1;
else
{
++n;
++beg0;
++beg1;
}
}
return n;
}
// Finds intersection between 2 sentences and divide it to the average sentence length
template<typename FwdIt0, typename FwdIt1>
double SmartAnalyzer::intersection_weight(FwdIt0 beg0, FwdIt0 end0, FwdIt1 beg1, FwdIt1 end1)
{
double const mid_size = 0.5 * (std::distance(beg0, end0) + std::distance(beg1, end1));
/* LINE 38 */ double const intsc = count_intersection(beg0, end0, beg1, end1, std::less<>(), double());
return intsc / mid_size;
}
When I try to compile it, I'm getting:
.. / lib / analyzer.cpp: In member function ‘double SmartAnalyzer::intersection_weight(FwdIt0, FwdIt0, FwdIt1, FwdIt1)’ :
.. / lib / analyzer.cpp : 38 : 76 : error : wrong number of template arguments(0, should be 1)
With GCC 4.7 on Debian
. I think this is somehow related with that GCC until 4.7+ doesn't support template alias, but I don't have any idea how I can fix it. I don't have the opportunity to update gcc to 4.8.