aboutsummaryrefslogtreecommitdiff
path: root/src/conditional
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-25 18:47:56 +0100
committerAdrian Kummerlaender2015-02-25 18:47:56 +0100
commite26621df352272688834361e7d026338cefb1372 (patch)
tree46064b5d0373e0b177791feaeaac86db086a685d /src/conditional
parenta3a0d6a1fa880b324576bb073637e021c57b0e65 (diff)
downloadTypeAsValue-e26621df352272688834361e7d026338cefb1372.tar
TypeAsValue-e26621df352272688834361e7d026338cefb1372.tar.gz
TypeAsValue-e26621df352272688834361e7d026338cefb1372.tar.bz2
TypeAsValue-e26621df352272688834361e7d026338cefb1372.tar.lz
TypeAsValue-e26621df352272688834361e7d026338cefb1372.tar.xz
TypeAsValue-e26621df352272688834361e7d026338cefb1372.tar.zst
TypeAsValue-e26621df352272688834361e7d026338cefb1372.zip
Added `Cond` branch condition assertion
* improves error messages in case no branch condition resolves to `true`
Diffstat (limited to 'src/conditional')
-rw-r--r--src/conditional/cond.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/conditional/cond.h b/src/conditional/cond.h
index 5f8014f..ca5e46d 100644
--- a/src/conditional/cond.h
+++ b/src/conditional/cond.h
@@ -12,12 +12,20 @@ namespace detail {
template <typename Pair>
using cond_predicate = IsTrue<Car<Pair>>;
+template <typename... Branches>
+struct select_cond_branch {
+ using type = Eval<detail::find_variadic<detail::cond_predicate, Branches...>>;
+
+ static_assert(
+ IsPair<type>::value,
+ "all branch conditions resolve to false"
+ );
+};
+
}
template <typename... Branches>
-using Cond = Cdr<Eval<
- detail::find_variadic<detail::cond_predicate, Branches...>
->>;
+using Cond = Cdr<Eval<detail::select_cond_branch<Branches...>>>;
template <
typename Condition,