Skip to content

Commit

Permalink
Use a mutable field instead of const_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 15, 2016
1 parent afb85a2 commit c50e941
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/context_free_grammar_generator.cpp
Expand Up @@ -142,7 +142,7 @@ std::string context_free_grammar_generator::print_nonterminal(const std::string&
picked = seed[seed_pos++] % got.possibilities_.size();
if (seed_pos >= seed_size) seed_pos = 0;
}
const_cast<unsigned int&>(got.last_) = picked; /* The variable last_ can change, the rest must stay const */
got.last_ = picked;
const std::vector<std::string>& used = got.possibilities_[picked];
for (unsigned int i = 0; i < used.size(); i++) {
if (used[i][0] == '{') result += print_nonterminal(used[i].substr(1), seed, seed_pos);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/context_free_grammar_generator.hpp
Expand Up @@ -29,7 +29,7 @@ class context_free_grammar_generator : public name_generator
struct nonterminal {
nonterminal() : last_(1) {}
std::vector<std::vector<std::string> > possibilities_;
unsigned int last_;
mutable unsigned int last_;
};

std::map<std::string, nonterminal> nonterminals_;
Expand Down

0 comments on commit c50e941

Please sign in to comment.