Ho la seguente classe:Perché questo parametro del modello predefinito non è consentito?
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_;
};
e si tenta di creare un'istanza di una variabile automatica come questo:
AlignedMemory blah(512, 512);
Questo dà il seguente errore:
src/cpfs/entry.cpp:438: error: missing template arguments before ‘blah’
Che cosa sto facendo di sbagliato ? void
non è un parametro predefinito consentito?
Avete qualche codice che include l'identificatore 'buf' ovunque? –
@Charles: 'buf' è un errore di battitura. Vedi questo: http://www.ideone.com/32gVl ... qualcosa manca alla mente. : P – Nawaz