algorithms that destruct and copy_construct

Posted by FredOverflow on Stack Overflow See other posts from Stack Overflow or by FredOverflow
Published on 2010-05-07T13:37:02Z Indexed on 2010/05/07 13:38 UTC
Read the original article Hit count: 154

Filed under:
|
|
|
|

I am currently building my own toy vector for fun, and I was wondering if there is something like the following in the current or next standard or in Boost?

template<class T>
void destruct(T* begin, T* end)
{
    while (begin != end)
    {
        begin -> ~T();
        ++begin;
    }
}

template<class T>
T* copy_construct(T* begin, T* end, T* dst)
{
    while (begin != end)
    {
        new(dst) T(*begin);
        ++begin;
        ++dst;
    }
    return dst;
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates