00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __LIST_HH
00019 # define __LIST_HH
00020
00021 # include <memory>
00022
00023 namespace aurelia {
00024
00025 struct list_nil {
00026 private:
00027 public:
00028 enum : unsigned { size = 0 };
00029 list_nil() {}
00030 list_nil(const list_nil&) {}
00031 list_nil(list_nil&&) {}
00032 };
00033
00034 template <typename T, typename Tail>
00035 struct list_cons {
00036 private:
00037 T h;
00038 Tail t;
00039
00040 public:
00041 enum : unsigned { size = (unsigned)(Tail::size)+1 };
00042
00043 list_cons(T&& h, const Tail& t):
00044 h(std::move(h)), t(t) {}
00045
00046 list_cons(T&& h, Tail&& t):
00047 h(std::move(h)), t(std::move(t)) {}
00048
00049 list_cons(const T& h, Tail&& t):
00050 h(h), t(std::move(t)) {}
00051
00052 list_cons(const T& h, const Tail& t):
00053 h(h), t(t) {}
00054
00055 list_cons(const list_cons& other):
00056 h(other.h), t(other.t) {}
00057
00058 list_cons(list_cons&& other):
00059 h(std::move(other.h)), t(std::move(other.t)) {}
00060
00061 const T& head() const {
00062 return h;
00063 }
00064
00065 const Tail& tail() const {
00066 return t;
00067 }
00068 };
00069
00070 template <typename H, typename T>
00071 H head(const list_cons<H,T>& l) {
00072 return l.head();
00073 }
00074
00075
00076 template <typename H, typename T>
00077 T tail(const list_cons<H,T>& l) {
00078 return l.tail();
00079 }
00080
00081 template <typename H, typename T>
00082 list_cons<H,T> cons(const H& h, const T& t) {
00083 return list_cons<H,T>(h, t);
00084 };
00085
00086 void head(list_nil);
00087
00088 list_nil tail(list_nil);
00089
00090 list_nil cons();
00091
00092 }
00093
00094 #endif