jeudi 1 mars 2018

I am not able to understand how new() operator is used in the following context. Can anyone explain me how?

The code I referred is in the link -> http://upcoder.com/3/roll-your-own-vector In this example, in the copyrange method, they are using new operator like in the below code.

  static void
copyRange(T* begin, T* end, T* dest)
{
    while(begin != end)
    {
        new((void*)dest) T(*begin);
        ++begin;
        ++dest;
    }
}

Can anyone explain how new() works in this context?

Aucun commentaire:

Enregistrer un commentaire