1
나는QMultiMap :: ConstIterator를 자체 템플릿 클래스에 사용할 수 있습니까?
QMultiMap<double, TSortable>::const_iterator it;`
을 사용하여 이상 QMultiMap
반복하고 싶지만 컴파일러는 모든 사용에 대한
error: ‘it’ was not declared in this scope
결과
error: expected ‘;’ before ‘it’
을 뿌려줍니다. 나는 ConstIterator
, const_iterator
그리고 심지어 더 느린 Iterator
을 아무런 성공없이 시도했다. Q (Multi) Map을 템플릿 클래스와 함께 사용할 수 있습니까? 정의 (void *와 같은)가 괜찮 으면 Iterator를 선언 할 수없는 이유는 무엇입니까?
#include <QtCore/QDebug>
#include <QtCore/QMap>
#include <QtCore/QMultiMap>
#include <limits>
/** TSortable has to implement minDistance() and maxDistance() */
template<class TSortable>
class PriorityQueue {
public:
PriorityQueue(int limitTopCount)
: limitTopCount_(limitTopCount), actMaxLimit_(std::numeric_limits<double>::max())
{
}
virtual ~PriorityQueue(){}
private:
void updateActMaxLimit(){
if(maxMap_.count() < limitTopCount_){
// if there are not enogh members, there is no upper limit for insert
actMaxLimit_ = std::numeric_limits<double>::max();
return;
}
// determine new max limit
QMultiMap<double, TSortable>::const_iterator it;
it = maxMap_.constBegin();
int act = 0;
while(act!=limitTopCount_){
++it;// forward to kMax
}
actMaxLimit_ = it.key();
}
const int limitTopCount_;
double actMaxLimit_;
QMultiMap<double, TSortable> maxMap_;// key=maxDistance
};
내 GCC (4.4.4 우분투)는'-Wall'에서도 오류를 표시하지 않습니다. – mbx