CppCommon  1.0.4.1
C++ Common Library
containers_list.cpp

Intrusive list container example

#include <iostream>
struct MyListNode : public CppCommon::List<MyListNode>::Node
{
int value;
MyListNode(int v) : value(v) {}
};
int main(int argc, char** argv)
{
MyListNode item1(123);
MyListNode item2(456);
MyListNode item3(789);
list.push_front(item1);
list.push_back(item2);
list.push_next(item2, item3);
while (list)
std::cout << "list.pop_front() = " << list.pop_front()->value << std::endl;
return 0;
}
Intrusive list container.
Definition: list.h:156
void push_next(T &base, T &item) noexcept
Push a new item as a next to the given one.
Definition: list.inl:118
void push_back(T &item) noexcept
Push a new item into the back of the list.
Definition: list.inl:105
T * pop_front() noexcept
Pop the item from the front of the list.
Definition: list.inl:144
void push_front(T &item) noexcept
Push a new item into the front of the list.
Definition: list.inl:92
Intrusive list container definition.