Skip to content

Commit ad092e2

Browse files
committed
Add a four-operand constructor to code_fort
This enables RAII rather then incremental construction.
1 parent 36c1fa5 commit ad092e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/std_code.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,20 @@ class code_fort:public codet
842842
operands().resize(4);
843843
}
844844

845+
/// A statement describing a for loop with initializer \p _init, loop
846+
/// condition \p _cond, increment \p _iter, and body \p _body.
847+
code_fort(
848+
const exprt &_init,
849+
const exprt &_cond,
850+
const exprt &_iter,
851+
const codet &_body)
852+
: codet(ID_for)
853+
{
854+
reserve_operands(4);
855+
add_to_operands(_init, _cond, _iter);
856+
add_to_operands(_body);
857+
}
858+
845859
// nil or a statement
846860
const exprt &init() const
847861
{

0 commit comments

Comments
 (0)