Add a PartialCall metafunction and use it so that vector transforms now can use normal metafunctions.
diff --git a/include/fruit/impl/meta/basics.h b/include/fruit/impl/meta/basics.h
index 2a9388f..c1a22ad 100644
--- a/include/fruit/impl/meta/basics.h
+++ b/include/fruit/impl/meta/basics.h
@@ -185,6 +185,27 @@
};
};
+// Call(PartialCall(F, Args...), MoreArgs...)
+//
+// is equivalent to:
+// Result = F(Args..., MoreArgs...)
+//
+// Note that you can't write:
+// PartialCall(F, Args...)(MoreArgs...)
+//
+// Because Call must be used to call metafunctions that are metaexpressions.
+struct PartialCall {
+ template <typename F, typename... Args>
+ struct apply {
+ struct type {
+ template <typename... MoreArgs>
+ struct apply {
+ using type = F(Args..., MoreArgs...);
+ };
+ };
+ };
+};
+
struct IsSame {
template <typename T, typename U>
struct apply {
diff --git a/include/fruit/impl/meta/proof_trees.h b/include/fruit/impl/meta/proof_trees.h
index 2d777f8..688b0aa 100644
--- a/include/fruit/impl/meta/proof_trees.h
+++ b/include/fruit/impl/meta/proof_trees.h
@@ -67,7 +67,7 @@
struct RemoveHpFromProofForest {
template <typename Hp, typename Forest>
struct apply {
- using type = TransformVector(Forest, Call(DeferArgs(RemoveHpFromProofTree), Hp));
+ using type = TransformVector(Forest, PartialCall(RemoveHpFromProofTree, Hp));
};
};
@@ -100,9 +100,8 @@
};
};
-template <typename NewProof>
struct CombineForestHypothesesWithProofHelper {
- template <typename Proof>
+ template <typename NewProof, typename Proof>
struct apply {
using type = If(IsInVector(typename NewProof::Th, typename Proof::Hps),
ConsProofTree(SetUnion(typename NewProof::Hps,
@@ -119,13 +118,12 @@
struct CombineForestHypothesesWithProof {
template <typename Forest, typename NewProof>
struct apply {
- using type = TransformVector(Forest, CombineForestHypothesesWithProofHelper<NewProof>);
+ using type = TransformVector(Forest, PartialCall(CombineForestHypothesesWithProofHelper, NewProof));
};
};
-template <typename Hps>
struct CombineProofHypothesesWithProof {
-template <typename Proof>
+template <typename Hps, typename Proof>
struct apply {
using type = If(IsInVector(typename Proof::Th, Hps),
typename Proof::Hps,
@@ -136,7 +134,7 @@
struct CombineProofHypothesesWithForestHelper {
template <typename Hps, typename Forest>
struct apply {
- using type = TransformVector(Forest, CombineProofHypothesesWithProof<Hps>);
+ using type = TransformVector(Forest, PartialCall(CombineProofHypothesesWithProof, Hps));
};
};
diff --git a/include/fruit/impl/meta/set.h b/include/fruit/impl/meta/set.h
index 18d4e24..642b342 100644
--- a/include/fruit/impl/meta/set.h
+++ b/include/fruit/impl/meta/set.h
@@ -98,9 +98,8 @@
Else>::type;
};
-template <typename S>
struct SetDifferenceHelper {
- template <typename T1>
+ template <typename S, typename T1>
struct apply {
using type = If(IsInVector(T1, S), None, T1);
};
@@ -109,13 +108,12 @@
struct SetDifference {
template <typename S1, typename S2>
struct apply {
- using type = TransformVector(S1, SetDifferenceHelper<S2>);
+ using type = TransformVector(S1, PartialCall(SetDifferenceHelper, S2));
};
};
-template <typename S>
struct SetIntersectionHelper {
- template <typename T1>
+ template <typename S, typename T1>
struct apply {
using type = If(IsInVector(T1, S), T1, None);
};
@@ -124,7 +122,7 @@
struct SetIntersection {
template <typename S1, typename S2>
struct apply {
- using type = TransformVector(S1, SetIntersectionHelper<S2>);
+ using type = TransformVector(S1, PartialCall(SetIntersectionHelper, S2));
};
};
diff --git a/include/fruit/impl/meta/vector.h b/include/fruit/impl/meta/vector.h
index 19a338a..3690a47 100644
--- a/include/fruit/impl/meta/vector.h
+++ b/include/fruit/impl/meta/vector.h
@@ -172,11 +172,15 @@
};
};
-template <typename ElemToRemove>
struct RemoveFromVectorHelper {
- template <typename Elem>
+ template <typename ElemToRemove, typename Elem>
struct apply {
- using type = If(IsSame(Elem, ElemToRemove), None, Elem);
+ using type = Elem;
+ };
+
+ template <typename Elem>
+ struct apply<Elem, Elem> {
+ using type = None;
};
};
@@ -184,7 +188,7 @@
struct RemoveFromVector {
template <typename T, typename V>
struct apply {
- using type = TransformVector(V, RemoveFromVectorHelper<T>);
+ using type = TransformVector(V, PartialCall(RemoveFromVectorHelper, T));
};
};