Some fun with stacks demonstrating various methods of getting values ββonto the stack from another container.
Assuming we have provided an appropriate definition for:
template<class T, class Container> auto stack_pusher(std::stack<T, Container>& stack);
Then we could write:
int main() { using namespace std;
for which the output will be:
8 1 7 2 6 3 5 4 4 5 3 6 2 7 1 8 6 5 7 4 * 3
Here is the full list (C ++ 14):
#include <iostream>
source share