#ifndef __MEMORY_AMV
#define __MEMORY_AMV
#include <new>
#include "exception.h"
#include "iterator.h"
namespace amv {
void newHandlerNew()
{
throw bad_alloc();
}
void enableMemoryException(bool status=true)
{
typedef void(*pnh)();
static pnh oldHandlerNew;
if(status)
oldHandlerNew=set_new_handler(newHandlerNew);
else
set_new_handler(oldHandlerNew);
}
template <class In, class For>
For uninitialized_copy(In begin, In end, For target)
{
typedef typename iterator_traits<For>::value_type type;
while(begin!=end)
{
new (static_cast<void *>(&*target)) type(*begin);
++begin;
++target;
}
return target;
}
template <class In, class For, class type>
For uninitialized_copy(In begin, In end, For target, const type &t)
{
while(begin!=end)
{
new (static_cast<void *>(&*target)) type(*begin);
++begin;
++target;
}
return target;
}
}
#endif