Boost logo

Boost Users :

From: Bryan Green (bgreen_at_[hidden])
Date: 2007-08-08 14:21:56


Vladimir Prus writes:
>
> 3. In this code:
>
> void
> typed_value<T, charT>::notify(const boost::any& value_store) const
> {
> - const T* value = boost::any_cast<const T>(&value_store);
> + const T* value;
> + if (value_store.empty())
> + value = boost::any_cast<const T>(&m_implicit_value);
> + else
> + value = boost::any_cast<const T>(&value_store);
> if (m_store_to) {
> *m_store_to = *value;
> }
>
>
> why value_store can end up being empty? I would expect that the xparse
> method, in the event that no explicit value is provided, would store
> m_implicit_value in value_store. The way you do this, it seems that
> the right value will be stored by 'notify', but the value stored
> to variables_map will be wrong.

I think you are correct about this.

>
> 6. I'd surely appreciate a test ;-)
>
> Do you think you can adjust the patch per above? Clearly, I'd need to code qu
> estions
> to be settled before applying this. I'd very much like test/comment changes
> too, but if you're out of time we can skip them.
 
I've created a new patch that I think takes all your suggestions into
account. I have modified 'example/options_description.cpp' to test it.
I also added tests to 'test/variable_map_test.cpp', but I don't know how to
compile/run it.

The new patch has been added to ticket #1131.

Regards,
Bryan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net