Skip to content

Instantly share code, notes, and snippets.

@njlr
Last active May 31, 2017 15:11
Show Gist options
  • Save njlr/2bb6a5e9d1c44d65ba5141b7be7e424d to your computer and use it in GitHub Desktop.
Save njlr/2bb6a5e9d1c44d65ba5141b7be7e424d to your computer and use it in GitHub Desktop.
template<class L, class R>
auto fold(L l, R r) {
using lTag = typename L::tag;
using rTag = typename R::tag;
if constexpr (is_base_of<rTag, BarTag>::value) {
if constexpr (is_same<lTag, FooTag>::value) {
return foldFB(l, r);
} else {
return foldBB(l, r);
}
} else {
return foldFF();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment