-
Notifications
You must be signed in to change notification settings - Fork 21
Description
const_cast gets used on const refs to Options (and GuardedOptions) objects in the following functions:
- T get(const Options&, const std::string&)
- T getNoBoundary(const Options&, const std::string&)
- bool isSetFinal(const Options&, const std::string&)
- bool isSetFinal(const GuardedOptions&, const std::string&)
- bool isSetFinalNoBoundary(const Options&, const std::string&)
- bool isSetFinalNoBoundary(const GuardedOptions&, const std::string&)
Even though the (Guarded)Options arguments are are logically const, the functions are modifying the attributes to mark that they have been read. This requires the const_cast.
I really don't like this. It doesn't look like
isSetFinalis called in any context with aconst&anyway? I know this is already an issue with the existing function, but can we avoid theconst_casthere?
Originally posted by @ZedThree in #421 (comment)
The introduction of access controls (#421) and automatic ordering of components (#428) might make this real-time checking redundant in future, in which case we'd be able to remove these attribute writes, but it will be best to battle-test these new features before removing anything.