#include
#include
#include
using namespace std;
using std::cout;
using std::cin;
template
class Vector{
public:
Vector():elements(0),first_free(0),my_end(0)
{
elements = alloc.allocate(16);
first_free = elements;
my_end = elements +16;
}
void push_back(const T& t)
{
if(first_free == my_end)
{
reallocate();
}
alloc.construct(first_free,t);
++first_free;
}
~Vector()
{
for(T *p = first_free; p != elements; )
{
alloc.destroy(–p);
}
if(elements)
{
alloc.deallocate(elements, my_end - elements );
}
}
private:
allocator alloc;
void reallocate()
{
std::ptrdiff_t size = first_free - elements;
std::ptrdiff_t newcapacity = 2*max(size,1);
T* newelements = alloc.allocate(newcapacity);
uninitialized_copy(elements,first_free,newelements);
for(T *p = first_free; p != elements; )
{
alloc.destroy(--p);
}
if(elements)
{
alloc.deallocate(elements, my_end - elements );
}
elements = newelements;
first_free = elements + size;
my_end = elements + newcapacity;
}
T* elements;
T* first_free;
T* my_end;
};
class A
{
public:
int arry[16];
};
int main()
{
Vector vector0;
int a = 5;
vector0.push_back(a);
int cin_1;
cin>>cin_1;
return 0;
}