assert() instead of throwing fc::null_optional exception when dereferencing an invalid optional. Before, the behavior was to throw null_optional in debug mode and to allow the dereference in release, which masked the error

This commit is contained in:
Eric Frias 2014-08-28 11:42:46 -04:00
parent 198d858d59
commit da15557c85

View file

@ -189,17 +189,17 @@ namespace fc {
// casts and comparisons, use valid() or !!
explicit operator bool()const { return _valid; }
T& operator*() { assert(assert_optional(_valid)); return ref(); }
const T& operator*()const { assert(assert_optional(_valid)); return ref(); }
T& operator*() { assert(_valid); return ref(); }
const T& operator*()const { assert(_valid); return ref(); }
T* operator->()
{
assert( assert_optional(_valid) );
assert(_valid);
return ptr();
}
const T* operator->()const
{
assert( assert_optional(_valid) );
assert(_valid);
return ptr();
}