CppCommon  1.0.4.1
C++ Common Library
containers_stack.cpp

Intrusive stack container example

#include <iostream>
struct MyStackNode : public CppCommon::Stack<MyStackNode>::Node
{
int value;
explicit MyStackNode(int v) : value(v) {}
};
int main(int argc, char** argv)
{
MyStackNode item1(123);
MyStackNode item2(456);
MyStackNode item3(789);
stack.push(item1);
stack.push(item2);
stack.push(item3);
while (stack)
std::cout << "stack.pop() = " << stack.pop()->value << std::endl;
return 0;
}
Intrusive stack container.
Definition: stack.h:106
void push(T &item) noexcept
Push a new item into the top of the stack.
Definition: stack.inl:56
T * pop() noexcept
Pop the item from the top of the stack.
Definition: stack.inl:64
Intrusive stack container definition.