The problem is that the variables map remembers which options are final.
If you look at the source you find the following entry.
/** Names of option with 'final' values -- which should not
be changed by subsequence assignments. */
std::set<std::string> m_final;
It's a private member variable of the variables_map.
I guess the easiest way would be using a new variables_map and replace the old one. If you need some of the old values, or just want to replace some of them, write your own store function. You basically create a temporary variables_map with po::store and then update your variables_map the way you need it.
The variables_map is basically a std::map so you can access its content the same way. It stores a po::variable_value, kind of a wrapper around a boost::any object.If you just want to replace a single value you can use something like that
template<class T>
void replace( std::map<std::string, po::variable_value>& vm, const std::string& opt, const T& val)
{
vm[option].value() = boost::any(val);
}
Note: po is a namespace alias.
namespace po = boost::program_options;