나는 다음과 같은 클래스가 :이 기본 템플릿 매개 변수가 허용되지 않는 이유는 무엇입니까?
template <typename Type = void>
class AlignedMemory {
public:
AlignedMemory(size_t alignment, size_t size)
: memptr_(0) {
int iret(posix_memalign((void **)&memptr_, alignment, size));
if (iret) throw system_error("posix_memalign");
}
virtual ~AlignedMemory() {
free(memptr_);
}
operator Type *() const { return memptr_; }
Type *operator->() const { return memptr_; }
//operator Type &() { return *memptr_; }
//Type &operator[](size_t index) const;
private:
Type *memptr_;
};
을 그리고이 같은 자동 변수의 인스턴스를 시도 :
src/cpfs/entry.cpp:438: error: missing template arguments before ‘blah’
내가 잘못 뭐하는 거지 :
AlignedMemory blah(512, 512);
이 다음과 같은 오류를 제공을 ? void
이 허용 된 기본 매개 변수가 아닙니까?
When default template-arguments are used, a template-argument list can be empty. In that case the empty
<>
brackets shall still be used as the template-argument-list.
식별자 'buf'가 포함 된 코드가 있습니까? –
@Charles :'buf'는 오타입니다. 이것을보십시오 : http://www.ideone.com/32gVl ... 마음이 있기 전에 뭔가가 빠져 있습니다. :피 – Nawaz