我有以下代码:
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)
链接器是否有任何混淆的原因?