nicer fixed step interface
This commit is contained in:
@@ -5,6 +5,14 @@ namespace intcode {
|
||||
BadInstruction::BadInstruction(char const* what)
|
||||
: std::runtime_error{what} {}
|
||||
|
||||
auto StepInput(Machine & m, ValueType input) -> void {
|
||||
std::get<Input>(Step(m)).pos = input;
|
||||
}
|
||||
|
||||
auto StepOutput(Machine & m) -> ValueType {
|
||||
return std::get<Output>(Step(m)).val;
|
||||
}
|
||||
|
||||
auto Step(Machine & m) -> std::variant<Input, Output, Halt> {
|
||||
for (;;) {
|
||||
auto instruction = m.Next();
|
||||
|
Reference in New Issue
Block a user