From a726f5fbb73d6a23ba7d3f9039518be297577d42 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Tue, 1 Oct 2013 09:05:53 -0700 Subject: [PATCH] feat(util/list): add static_asserts for map/for_each/compare --- src/util/list_fn.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/list_fn.h b/src/util/list_fn.h index d989d31db..9ef5359d8 100644 --- a/src/util/list_fn.h +++ b/src/util/list_fn.h @@ -108,6 +108,8 @@ list append(list const & l1, list const & l2) { */ template list map(list const & l, F f) { + static_assert(std::is_same::type, T>::value, + "map: return type of f is not sxpr"); if (is_nil(l)) { return l; } else { @@ -120,6 +122,8 @@ list map(list const & l, F f) { */ template void for_each(list const & l, F f) { + static_assert(std::is_same::type, void>::value, + "for_each: return type of f is not void"); if (is_nil(l)) { return; } else { @@ -133,6 +137,8 @@ void for_each(list const & l, F f) { */ template bool compare(list const & l1, list const & l2, P p) { + static_assert(std::is_same::type, bool>::value, + "compare: return type of f is not bool"); auto it1 = l1.begin(); auto it2 = l2.begin(); auto end1 = l1.end();