From 27aaee43499c268903332c7e9e1e6ec2d193dc3a Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 6 Feb 2015 19:26:26 +0100 Subject: Revamped to use `Cons` as a function and `Pair` as its result * this is analogous to _Scheme_ where a pair (dot-expression) is returned from a call to `cons` * `Head` and `Tail` are kept as direct references to the `CAR` and `CDR` values of a pair to match e.g. the math operators --- src/pair.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/pair.h (limited to 'src/pair.h') diff --git a/src/pair.h b/src/pair.h new file mode 100644 index 0000000..20bef4e --- /dev/null +++ b/src/pair.h @@ -0,0 +1,26 @@ +#ifndef TYPEASVALUE_SRC_PAIR_H_ +#define TYPEASVALUE_SRC_PAIR_H_ + +#include + +namespace tav { + +namespace detail { struct pair_tag { }; } + +template < + typename CAR, + typename CDR +> +struct Pair : detail::pair_tag { + typedef CAR car; + typedef CDR cdr; + + typedef Pair type; +}; + +template +using IsPair = std::is_base_of; + +} + +#endif // TYPEASVALUE_SRC_PAIR_H_ -- cgit v1.2.3