P
Protoman
Is this a good method of repersenting an allocator?:
template <class T, long long X>
class Allocator
{
public:
Allocator(){}
T* allocate()
{
static long long i=0;
T* j=new(&pool) T;
i++;
if(i>X)throw bad_alloc();
else return &*j;
}
private:
static T pool[X];
};
template<class T,long long X> T Allocator<T,X>:ool[X];
Any suggestions? Thanks!!!
template <class T, long long X>
class Allocator
{
public:
Allocator(){}
T* allocate()
{
static long long i=0;
T* j=new(&pool) T;
i++;
if(i>X)throw bad_alloc();
else return &*j;
}
private:
static T pool[X];
};
template<class T,long long X> T Allocator<T,X>:ool[X];
Any suggestions? Thanks!!!