
Wouldn't the following work? if( t && *t == mT ) Pablo Aguilar Marc Mutz wrote:
Hi,
In 1.33.1, comparing an optional<T> to it's T fails, since although T implicitly converts to optional<T>, op== being templated, implicit conversions are not considered. Is this by design? If so, what's the rationale for this? I repeatedly find myself in the need to compare an optional<T> member to a passed in T, e.g. in a setT( const T & ), in order to check for a no-op operation and suppress notifications in this case, e.g.:
class Foo { boost::optional<T> mT; boost::signal< void(const optional<T>&) > tChangedSignal; void setT( const T & t ) { if ( t == mT ) return; mT = t; tChangedSignal( mT ); // mark cached values dirty, etc, etc... } };