aboutsummaryrefslogtreecommitdiff
path: root/src/conditional/cond.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-12 14:32:33 +0100
committerAdrian Kummerlaender2015-02-12 14:32:33 +0100
commit246cb31c1e20cdcc21a6a607de4b0095c71315d6 (patch)
tree0301c23d9c09b0a578413019a2d27f75cf69a374 /src/conditional/cond.h
parent4bb200de716891ed6c9fc182311c02685c8bdfd4 (diff)
downloadTypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.gz
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.bz2
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.lz
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.xz
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.zst
TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.zip
Implemented `Cond` conditional
* returns the `CDR` of the first true `CAR` in a given list of pairs * reimplemented `Apply` base class selection in terms of `Cond`
Diffstat (limited to 'src/conditional/cond.h')
-rw-r--r--src/conditional/cond.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/conditional/cond.h b/src/conditional/cond.h
new file mode 100644
index 0000000..0c2b1a8
--- /dev/null
+++ b/src/conditional/cond.h
@@ -0,0 +1,29 @@
+#ifndef TYPEASVALUE_SRC_CONDITIONAL_COND_H_
+#define TYPEASVALUE_SRC_CONDITIONAL_COND_H_
+
+#include <type_traits>
+
+#include "list/list.h"
+#include "list/operation/higher/find.h"
+
+namespace tav {
+
+template <typename... Branches>
+class Cond {
+ private:
+ template <typename Pair>
+ using predicate = IsTrue<typename Car<Pair>::type::type>;
+
+ public:
+ typedef typename Cdr<
+ typename Find<
+ predicate,
+ typename List<Branches...>::type
+ >::type
+ >::type type;
+
+};
+
+}
+
+#endif // TYPEASVALUE_SRC_CONDITIONAL_COND_H_