【发布时间】:2011-04-27 23:40:47
【问题描述】:
所以我尝试在我的实用程序类中使用通用比较函子。
我尝试定义它并这样称呼它
template <class T>
bool AVL_tree<T>::avl_insert(AVL_Node<T> *& top, const AVL_Node<T> * insertNode, bool & taller) {
std::binary_function<T,T,bool>::first_argument_type insertNodeValue;
insertNodeValue = insertNode->data;
std::binary_function<T,T,bool>::second_argument_type topValue;
topValue = insertNode->data;
std::binary_function<T,T,bool>::result_type cmp_result;
cmp_result = comparer(insertNodeValue,topValue);
std::binary_function<T,T,bool>::result_type cmp_result2;
cmp_result2 = comparer(topValue,insertNodeValue);
//Function continues from here
}
预期会出现特定的编译器错误;在插入节点值之前
topValue 和 cmp_result 重复出现此错误;
我真的不明白为什么这是一个语法错误,我正在处理这个参考: http://www.cplusplus.com/reference/std/functional/binary_function/
【问题讨论】:
-
为什么这一切:
std::binary_function<T,T,bool>::first_argument_type?而不仅仅是T?
标签: c++ g++ compiler-errors