For example,building the comparison criteria into a sort function is unacceptable because the same
data can be sorted according to different criteria. This is why the C standard libraryqsort()
takes a comparison function as an argument rather than relying on something fixed,say,the < operator. On the other hand,the overhead imposed by a function call for each comparison compromisesqsort()
as a building block for further library building.
以上这些对我有意义.但在第二段中,
Is that overhead serIoUs? In most cases,probably not. However,the function call overhead can
dominate the execution time for some algorithms and cause users to seek alternatives. The technique of supplying comparison criteria through a template argument described in §13.4 solves that
problem.
在§13.4中,比较标准被定义为具有静态成员函数的类(进行比较).当这些类用作模板参数时,仍然通过其静态成员函数进行比较.在我看来,仍然会有调用静态成员函数的开销.
Stroustrup的意思是什么?