Use a mutable field instead of const_cast
This commit is contained in:
parent
afb85a2000
commit
c50e941af7
2 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
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_;
|
||||
|
|
Loading…
Add table
Reference in a new issue