Skip to content

Commit c0a9f52

Browse files
danpoePetr Bauch
authored and
Petr Bauch
committed
Add templates to call check(), validate(), or validate_full() on a given object
1 parent 86e61fe commit c0a9f52

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/util/validate.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,42 @@ enum class validation_modet
6666
} \
6767
} while(0)
6868

69+
template <typename T>
70+
struct call_checkt
71+
{
72+
static_assert(std::is_base_of<irept, T>::value, "");
73+
74+
void operator()(const irept &irep, const validation_modet vm)
75+
{
76+
const T &s = static_cast<const T &>(irep);
77+
s.check(vm);
78+
}
79+
};
80+
81+
template <typename T>
82+
struct call_validatet
83+
{
84+
static_assert(std::is_base_of<irept, T>::value, "");
85+
86+
void
87+
operator()(const irept &irep, const namespacet &ns, const validation_modet vm)
88+
{
89+
const T &s = static_cast<const T &>(irep);
90+
s.validate(ns, vm);
91+
}
92+
};
93+
94+
template <typename T>
95+
struct call_validate_fullt
96+
{
97+
static_assert(std::is_base_of<irept, T>::value, "");
98+
99+
void
100+
operator()(const irept &irep, const namespacet &ns, const validation_modet vm)
101+
{
102+
const T &s = static_cast<const T &>(irep);
103+
s.validate_full(ns, vm);
104+
}
105+
};
106+
69107
#endif /* CPROVER_UTIL_VALIDATE_H */

0 commit comments

Comments
 (0)