Listing 3: An STL-style algorithm with compile-time branching, using the _Iter_cat kludge. The internal helpers are as in Listing 2

template<typename _It>
double Alg(_It it1, _It it2)
{
  return AlgInternal(
    it1,
    it2,
    std::_Iter_cat(it1)
    );
}
— End of Listing —