diff options
| author | Roland Reichwein <mail@reichwein.it> | 2020-02-19 21:48:29 +0100 | 
|---|---|---|
| committer | Roland Reichwein <mail@reichwein.it> | 2020-02-19 21:48:29 +0100 | 
| commit | ba8520d3435c75c2568c05f1333966a4c1a4d69b (patch) | |
| tree | 3962992ee6835cf5ad4651e12c852b5dd73e6f8d /grammer.cpp | |
| parent | d10f91dce5ecc2643496b7ef78149c0cdf37aaae (diff) | |
Fix invalid reference bug
Diffstat (limited to 'grammer.cpp')
| -rw-r--r-- | grammer.cpp | 11 | 
1 files changed, 7 insertions, 4 deletions
| diff --git a/grammer.cpp b/grammer.cpp index 9df4703..a54b65d 100644 --- a/grammer.cpp +++ b/grammer.cpp @@ -374,7 +374,7 @@ std::map<std::string, std::string> Compiler::traverse(const std::string& lower,   std::deque<std::pair<std::string, std::string>> todo{{lower, ""}}; // node, child   while (!todo.empty()) { -  auto& [current_node, current_child] = todo.front(); +  auto [current_node, current_child] = todo.front();    std::string& current_node2{current_node}; // workaround for lambda capture below (clang 8)    todo.pop_front(); @@ -387,11 +387,13 @@ std::map<std::string, std::string> Compiler::traverse(const std::string& lower,      visited[current_node] = current_child; -    std::for_each(parents.begin(), parents.end(), [&](const auto&x) {todo.emplace_back(x, current_node2);}); +    std::for_each(parents.begin(), parents.end(), [&](const auto&x) { +     todo.push_back({x, current_node2}); +    });     }    }   } -  +   return visited;  } @@ -413,8 +415,9 @@ std::vector<std::string> Compiler::GetPath(std::string upper, std::string lower)     result.push_back(current);     current = child; -  } else +  } else {     return {}; +  }   }   return result;  } | 
