How to initialize std stack with std vector?
问题 I need to put an std::vector into an std::stack . Here is my method so far(I am building a card game) : void CardStack::initializeCardStack(std::vector<Card> & p_cardVector) { m_cardStack = std::stack<Card>(); //code that should initialize m_cardStack with p_cardVector } Note : I cannot change my method signature because it is a imposed by a teacher... Do I have to iterate over the whole vector ? What is the most efficient way to do this ? The documentation. I have tried Jens answer but it