Skip to content

Commit cf2c4bf

Browse files
author
Daniel Kroening
committed
introduce make_boolean_expr
This is a type-safe drop-in replacement for exprt::make_bool(value).
1 parent 458ae26 commit cf2c4bf

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/util/std_expr.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ bool constant_exprt::value_is_zero_string() const
2525
return val.find_first_not_of('0')==std::string::npos;
2626
}
2727

28+
constant_exprt make_boolean_expr(bool value)
29+
{
30+
if(value)
31+
return true_exprt();
32+
else
33+
return false_exprt();
34+
}
35+
2836
exprt disjunction(const exprt::operandst &op)
2937
{
3038
if(op.empty())

src/util/std_expr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4121,6 +4121,9 @@ class false_exprt:public constant_exprt
41214121
}
41224122
};
41234123

4124+
/// \brief returns true_exprt if given true and false_exprt otherwise
4125+
constant_exprt make_boolean_expr(bool);
4126+
41244127
/// \brief The NIL expression
41254128
class nil_exprt : public nullary_exprt
41264129
{

0 commit comments

Comments
 (0)