jeudi 24 décembre 2015

Copy elements from std::vector into std::stack c++

I need to copy std::vector into std::stack.

  1. Is traversing over vector and pushing into stack is only the way?

  2. If there is another way what is better choice from performance point of view?

std::stack<A>   m_stack;
std::vector<A>  m_vec;

for (auto& elem : m_vec)
{
    m_stack.push(elem);
}

Aucun commentaire:

Enregistrer un commentaire