2
템플릿과 관련하여 매우 이상한 문제가 있습니다. 오류가 발생했습니다 error: ‘traits’ is not a template
. 샘플 테스트 프로젝트에서 문제를 재현 할 수 없었습니다. 그러나 그것은 내 프로젝트에서 발생합니다 (이 글은 제가 게시 할 수있는 것보다 큽니다).오류 : '특성'이 템플릿이 아닙니다. - C++
어쨌든 다음 파일과 사용법은 다음과 같습니다. 누구든지이 오류가 발생할 때 어떤 생각을 가지고 있습니까?
다음은 traits.hpp
입니다.
namespace silc
{
template<class U>
struct traits<U>
{
typedef const U& const_reference;
};
template<class U>
struct traits<U*>
{
typedef const U* const_reference;
};
}
다른 헤더 파일에서 사용됩니다.
namespace silc {
template<typename T>
class node {
public:
typedef typename traits<T>::const_reference const_reference;
const_reference value() const {
/* ... */
}
}
}
감사합니다. 그것은 내가 한 바보 같은 실수였다. 다시 지적 해 주셔서 감사합니다. –