@@ -158,14 +158,14 @@ void StagePrivate::sendForward(const InterfaceState& from, InterfaceState&& to,
158158
159159 me ()->forwardProperties (from, to);
160160
161- auto to_it = states_. insert (states_. end (), std::move (to));
161+ InterfaceState* to_stored{ storeState ( std::move (to)) } ;
162162
163163 // register stored interfaces with solution
164164 solution->setStartState (from);
165- solution->setEndState (*to_it );
165+ solution->setEndState (*to_stored );
166166
167167 if (!solution->isFailure ())
168- nextStarts ()->add (*to_it );
168+ nextStarts ()->add (*to_stored );
169169
170170 newSolution (solution);
171171}
@@ -180,13 +180,13 @@ void StagePrivate::sendBackward(InterfaceState&& from, const InterfaceState& to,
180180
181181 me ()->forwardProperties (to, from);
182182
183- auto from_it = states_. insert (states_. end (), std::move (from));
183+ InterfaceState* from_stored{ storeState ( std::move (from)) } ;
184184
185- solution->setStartState (*from_it );
185+ solution->setStartState (*from_stored );
186186 solution->setEndState (to);
187187
188188 if (!solution->isFailure ())
189- prevEnds ()->add (*from_it );
189+ prevEnds ()->add (*from_stored );
190190
191191 newSolution (solution);
192192}
@@ -199,8 +199,8 @@ void StagePrivate::spawn(InterfaceState&& state, const SolutionBasePtr& solution
199199 if (!storeSolution (solution, nullptr , nullptr ))
200200 return ; // solution dropped
201201
202- auto from = states_. insert (states_. end (), InterfaceState ( state)); // copy
203- auto to = states_. insert (states_. end (), std::move (state));
202+ InterfaceState* from{ storeState ( InterfaceState{ state }) };
203+ InterfaceState* to{ storeState ( std::move (state)) } ;
204204
205205 solution->setStartState (*from);
206206 solution->setEndState (*to);
@@ -275,6 +275,10 @@ void StagePrivate::computeCost(const InterfaceState& from, const InterfaceState&
275275 }
276276}
277277
278+ InterfaceState* StagePrivate::storeState (InterfaceState&& state) {
279+ return &*states_.insert (states_.end (), std::move (state));
280+ }
281+
278282Stage::Stage (StagePrivate* impl) : pimpl_(impl) {
279283 assert (impl);
280284 auto & p = properties ();
0 commit comments