Created
February 2, 2016 08:56
-
-
Save gazliddon/da9c44e411f737fba10a to your computer and use it in GitHub Desktop.
everyone ends up writing lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CONS_H_15URYTVP | |
#define CONS_H_15URYTVP | |
#include <tuple> | |
#include "list.h" | |
namespace shitlib { | |
namespace mpl { | |
namespace detail { | |
template< typename... ARGS> | |
struct cons_detail { | |
using type = list<ARGS...>; | |
}; | |
template<typename VAL> | |
struct cons_detail<VAL> { | |
using type = list<VAL>; | |
}; | |
template<typename VAL, typename... ARGS> | |
struct cons_detail<VAL, list<ARGS...>> { | |
using type = list<VAL, ARGS...>; | |
}; | |
} /* detail */ | |
template<typename... ARGS> | |
using cons = typename detail::cons_detail<ARGS...>::type; | |
static_assert(std::is_same< | |
cons<>, | |
list<>>{} | |
, ""); | |
static_assert(std::is_same< | |
cons<int>, | |
list<int>>{} | |
, ""); | |
static_assert(std::is_same< | |
cons<int,float,double>, | |
list<int,float,double>>{} | |
, ""); | |
static_assert(std::is_same< | |
cons<int, list<float, char, double>>, | |
list<int,float,char,double>>{} | |
, ""); | |
} /* mpl */ | |
} /* shitlib */ | |
#endif /* end of include guard: CONS_H_15URYTVP */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment