This seems to "work":
case token_type::rbrace:
{
auto it = output_stack.rbegin();
while (it->type() != token_type::lbrace)
{
assert(it->type() == token_type::expression);
auto expr = std::move(it->expr_);
++it;
assert(it->type() == token_type::key);
auto key = std::move(it->key_);
++it;
}
assert(it->type() == token_type::lbrace);
output_stack.erase(it.base(), output_stack.end());
output_stack.pop_back();
break;
}
It seems connected to moving twice or more from `output_stack.back()`.
If this solves your problem then it's proof that I can fix code without
understanding it.
- Alf
PS: The two statements before `break;` can probably be expressed with
just one vector operation, more clean IMHO.
PPS: Consider using `std::variant` instead of creating your own
discriminated union.