#include using namespace std; struct _EmptyList { void write() const {} }; template struct _AddNode { typedef _Next Next; typedef _Item Item; const Item item; const Next& next; _AddNode(const Item& _item, const Next& _next) : item(_item), next(_next) {} void write() const { next.write(); cout << item << ' '; } }; template struct _Writer { typedef _List List; const List list; _Writer(const List& _list = List()) : list(_list) {} template _Writer<_AddNode > add(Item item) const { return _Writer<_AddNode >(_AddNode(item, list)); } void write() const { list.write(); cout << endl; } }; typedef _Writer<> Writer; int main() { Writer().add(3).add("alpha").add(4.53).write(); }