带比较器的关联容器(multiset)
C++ Primer第四版中15.8.3句柄一节中有下面的内容:
inline bool compare(const Sale_item& lhs, const Sale_item& rhs)
{
return lhs.book<rhs.book;
}
typedef bool (*Comp)(const Sale_item&, const Sale_item&);
std::multiset<Sale_item, Comp > items(compare);
Comp是函数的指针,compare是个函数,最后一句是什么意思?能将一个函数名作为参数传递给容器吗?