看看这段代码:
template<class T, class Compare>
void foo(const std::set<T, Compare> & bar)
{
// here I need the comparative function BUT with another type
// like this:
if (Compare<float>()(...))
}就像这样,但不管用:
template<class T, class Compare>
void foo(const std::set<T, Compare<T>> & bar)
...有可能吗?
发布于 2014-07-04 10:17:53
您需要一个模板参数:
template<class T, template<class> class Compare>现在,Compare模板参数本身就是一个模板。
https://stackoverflow.com/questions/24571997
复制相似问题