From da15557c85820b0ef5e1a4d21d0d2858cbf0d931 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Thu, 28 Aug 2014 11:42:46 -0400 Subject: [PATCH] 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 --- include/fc/optional.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fc/optional.hpp b/include/fc/optional.hpp index 6adea6a..711e89e 100644 --- a/include/fc/optional.hpp +++ b/include/fc/optional.hpp @@ -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(); }