mardi 4 août 2020

Calling move constructor inside the copy constructor

I passed by the following code:

void enqueue(T&& value)
{
    move_value_somewhere( T(std::move(value)));
}

void enqueue(const T& value)
{
    enqueue(T(value));
}

The move constructor is called inside the copy constructor, assuming the code is correct, how is that T(std::move(value)) doesn't move the value instead of copying it if it's called from copy constructor?, it's probably from T() but i don't why !!

Aucun commentaire:

Enregistrer un commentaire