无法将Lambda函数传递给模板化类C ++

时间:2018-08-01 22:49:07

标签: c++ c++11 templates lambda

我有以下代码:

template <class T>
BinaryHeap<T>::BinaryHeap(std::function<bool(T, T)> isHigherPriority)
{
    m_isHigherPriority = isHigherPriority;
}

...

std::function<bool(int, int)> isHigherPriority = [](int a, int b) { return a <= b;  };
BinaryHeap<int> heap(isHigherPriority);

代码似乎可以正常编译,但是我得到链接器一个链接器错误: LNK2019无法解析的外部符号“ public:__thiscall BinaryHeap :: BinaryHeap(class std :: function)”(?? 0?$ BinaryHeap @ H @@ QAE @ V?$ function @ $$ A6A_NHH @ Z @ std @@@@ Z)

链接器是否有任何混淆的原因?

0 个答案:

没有答案