Add static_asserts for higher-order functions in kernel/for_each.h and kernel/pp.cpp
This commit is contained in:
parent
e5fe016a44
commit
a1229692b0
2 changed files with 5 additions and 1 deletions
|
@ -13,6 +13,8 @@ template<typename F>
|
||||||
class for_each_fn {
|
class for_each_fn {
|
||||||
expr_cell_offset_set m_visited;
|
expr_cell_offset_set m_visited;
|
||||||
F m_f;
|
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) {
|
void apply(expr const & e, unsigned offset) {
|
||||||
if (is_shared(e)) {
|
if (is_shared(e)) {
|
||||||
|
|
|
@ -117,6 +117,8 @@ struct pp_fn {
|
||||||
|
|
||||||
template<typename It>
|
template<typename It>
|
||||||
format pp_bnames(It const & begin, It const & end, bool use_line) {
|
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;
|
auto it = begin;
|
||||||
format r = pp_bname(*it);
|
format r = pp_bname(*it);
|
||||||
++it;
|
++it;
|
||||||
|
|
Loading…
Reference in a new issue