I have the following class:
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_;
};
And attempt to instantiate an automatic variable like this:
AlignedMemory blah(512, 512);
This gives the following error:
src/cpfs/entry.cpp:438: error: missing template arguments before ‘blah’
What am I doing wrong? Is void
not an allowed default parameter?
buf
anywhere? – Townsfolkbuf
is a typo. See this : ideone.com/32gVl ... something is missing before mind. :P – Cella