#include <iostream>

using namespace std;


struct _EmptyList {
  void write() const {}
};

template <typename _Item, typename _Next>
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 <typename _List = _EmptyList>
struct _Writer {
  typedef _List List;

  const List list;

  _Writer(const List& _list = List()) : list(_list) {}

  
  template <typename Item> _Writer<_AddNode<Item, List> > add(Item item) const {
    return _Writer<_AddNode<Item, List> >(_AddNode<Item, List>(item, list));
  }

  void write() const {
    list.write();
    cout << endl;
  }
};


typedef _Writer<> Writer;

int main() {
  Writer().add(3).add("alpha").add(4.53).write();
}
