$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Marc Mutz (marc_at_[hidden])
Date: 2006-03-14 02:34:47
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...
  }
};
-- Marc Mutz -- marc_at_[hidden], mutz_at_[hidden] Klarälvdalens Datakonsult AB, Platform-independent software solutions