Art*_*ium 1 c++ templates derived avl-tree
我希望此代码是可能的。
template<typename K, typename T, typename Comparer>
class AVLTree
{
...
void foo() {
...
int res = Comparer::compare(key1, key2);
...
}
...
};
Run Code Online (Sandbox Code Playgroud)
具体来说,我想强制Comparer类具有一个static int compare(K key1, K key2)功能。我当时正在考虑使用推导,但是找不到任何适用于模板的想法。
谢谢。