Skip to content

Commit b032b00

Browse files
author
Daniel Kroening
committed
rvalue variants of exprt::copy_to_operands
1 parent 2dc9574 commit b032b00

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/util/expr.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ class exprt:public irept
121121
operands().push_back(expr);
122122
}
123123

124+
/// Copy the given argument to the end of `exprt`'s operands.
125+
/// \param expr: `exprt` to append to the operands
126+
void copy_to_operands(exprt &&expr)
127+
{
128+
operands().push_back(std::move(expr));
129+
}
130+
124131
/// Copy the given arguments to the end of `exprt`'s operands.
125132
/// \param e1: first `exprt` to append to the operands
126133
/// \param e2: second `exprt` to append to the operands
@@ -134,6 +141,19 @@ class exprt:public irept
134141
op.push_back(e2);
135142
}
136143

144+
/// Copy the given arguments to the end of `exprt`'s operands.
145+
/// \param e1: first `exprt` to append to the operands
146+
/// \param e2: second `exprt` to append to the operands
147+
void copy_to_operands(exprt &&e1, exprt &&e2)
148+
{
149+
operandst &op = operands();
150+
#ifndef USE_LIST
151+
op.reserve(op.size() + 2);
152+
#endif
153+
op.push_back(std::move(e1));
154+
op.push_back(std::move(e2));
155+
}
156+
137157
/// Copy the given arguments to the end of `exprt`'s operands.
138158
/// \param e1: first `exprt` to append to the operands
139159
/// \param e2: second `exprt` to append to the operands
@@ -149,6 +169,21 @@ class exprt:public irept
149169
op.push_back(e3);
150170
}
151171

172+
/// Copy the given arguments to the end of `exprt`'s operands.
173+
/// \param e1: first `exprt` to append to the operands
174+
/// \param e2: second `exprt` to append to the operands
175+
/// \param e3: third `exprt` to append to the operands
176+
void copy_to_operands(exprt &&e1, exprt &&e2, exprt &&e3)
177+
{
178+
operandst &op = operands();
179+
#ifndef USE_LIST
180+
op.reserve(op.size() + 3);
181+
#endif
182+
op.push_back(std::move(e1));
183+
op.push_back(std::move(e2));
184+
op.push_back(std::move(e3));
185+
}
186+
152187
void make_typecast(const typet &_type);
153188
void make_not();
154189

0 commit comments

Comments
 (0)