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:
parent
198d858d59
commit
da15557c85
1 changed files with 4 additions and 4 deletions
|
|
@ -189,17 +189,17 @@ namespace fc {
|
||||||
// casts and comparisons, use valid() or !!
|
// casts and comparisons, use valid() or !!
|
||||||
explicit operator bool()const { return _valid; }
|
explicit operator bool()const { return _valid; }
|
||||||
|
|
||||||
T& operator*() { assert(assert_optional(_valid)); return ref(); }
|
T& operator*() { assert(_valid); return ref(); }
|
||||||
const T& operator*()const { assert(assert_optional(_valid)); return ref(); }
|
const T& operator*()const { assert(_valid); return ref(); }
|
||||||
|
|
||||||
T* operator->()
|
T* operator->()
|
||||||
{
|
{
|
||||||
assert( assert_optional(_valid) );
|
assert(_valid);
|
||||||
return ptr();
|
return ptr();
|
||||||
}
|
}
|
||||||
const T* operator->()const
|
const T* operator->()const
|
||||||
{
|
{
|
||||||
assert( assert_optional(_valid) );
|
assert(_valid);
|
||||||
return ptr();
|
return ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue