내가 멤버 함수 모멘트 (전문하려고 해요) 만 (안 구멍 클래스) :CPP이 같은 템플릿 멤버 함수 전문
실제 전문화 추가 abstractWaveletSpecialization 구조체에서 발생template<class Derived, class T>
class AbstractWavelet {
public:
[...]
template<bool useCache>
const typename T::scalar moment(const int i, const int j) const {
return abstractWaveletSpecialization<Derived, T, useCache>::moment(static_cast<const Derived*>(this), i, j);
}
template<bool useCache>
friend const typename T::scalar abstractWaveletSpecialization<Derived, T, useCache>::moment(const Derived* const that, const int i, const int j);
protected:
// returns the jth moment of the ith scaling function
template<bool useCache>
inline const typename T::scalar momentImpl(const int j, const int i) const {
[...]
} // momentImpl
};
:
error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘bool’ to binary ‘operator<’
012 :
template<class Derived, class T, bool useCache>
struct abstractWaveletSpecialization {
inline static const typename T::scalar moment(const Derived* const that, const int i, const int j) {
return that->momentImpl<useCache>(i,j);
}
};
template<class Derived, class T>
struct abstractWaveletSpecialization<Derived, T, true> {
typedef const std::pair<const int, const int> momentCacheKey;
typedef std::map<momentCacheKey,
const typename T::scalar> momentCacheType;
static momentCacheType momentCache;
inline static const typename T::scalar moment(const Derived* const that, const int i, const int j) {
momentCacheKey cacheKey(i,j);
typename momentCacheType::iterator idx = momentCache.find(cacheKey);
if (idx == momentCache.end())
return that->momentImpl<true>(i, j); // COMPILE ERROR HERE
else
return momentCache[cacheKey];
}
};
문제는 내가 전문 abstractWaveletSpecialization 구조체에 momentImpl()를 호출 할 수 없다는 것입니다
하지만 컴파일러는 특수화되지 않은 abstractWaveletSpecialization 구조체에서 momentImpl 호출에 대해 불평하지 않습니다.
내 접근법이 C++에서 금지되어 있습니까? 아니면이 방법을 만들 수있는 방법이 있습니까?
[템플릿과 "typename"키워드를 어디에 왜 넣어야합니까?] (http : //stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – ecatmur