Add static_asserts for higher-order functions in kernel/for_each.h and kernel/pp.cpp

This commit is contained in:
Soonho Kong 2013-08-08 16:12:27 -07:00
parent e5fe016a44
commit a1229692b0
2 changed files with 5 additions and 1 deletions

View file

@ -13,6 +13,8 @@ template<typename F>
class for_each_fn {
expr_cell_offset_set m_visited;
F m_f;
static_assert(std::is_same<typename std::result_of<F(expr const &, unsigned)>::type, void>::value,
"for_each_fn: return type of m_f is not void");
void apply(expr const & e, unsigned offset) {
if (is_shared(e)) {

View file

@ -117,6 +117,8 @@ struct pp_fn {
template<typename It>
format pp_bnames(It const & begin, It const & end, bool use_line) {
static_assert(std::is_same<typename std::iterator_traits<It>::value_type, expr>::value,
"pp_bnames takes an argument which is not an iterator containing expr.");
auto it = begin;
format r = pp_bname(*it);
++it;