From 0446f49e7db6348d28db1fcdd1fe00e3ccd8149b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 2 Apr 2017 06:49:05 +0200 Subject: [PATCH] resolve some further uses implicit bool conversion trickery (closes #178) --- src/common/instancehandle.hpp | 11 ++--------- src/lib/wrapper.hpp | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/common/instancehandle.hpp b/src/common/instancehandle.hpp index a9def2834..08f26e7b5 100644 --- a/src/common/instancehandle.hpp +++ b/src/common/instancehandle.hpp @@ -180,8 +180,6 @@ namespace lumiera { I* instance_; facade::Link facadeLink_; - typedef InstanceHandle _ThisType; - public: /** Set up an InstanceHandle representing a plugin. * Should be placed at the client side. @@ -231,13 +229,8 @@ namespace lumiera { - typedef I* _ThisType::*unspecified_bool_type; - - /** implicit conversion to "bool" */ - operator unspecified_bool_type() const // never throws - { return isValid()? &_ThisType::instance_ : 0; } - - bool operator! () const { return not isValid(); } + explicit operator bool() const { return isValid(); } + bool operator! () const { return not isValid();} private: diff --git a/src/lib/wrapper.hpp b/src/lib/wrapper.hpp index b5edbe7ad..45d73fa88 100644 --- a/src/lib/wrapper.hpp +++ b/src/lib/wrapper.hpp @@ -395,8 +395,8 @@ namespace wrapper { Res& operator*() const { return *lastResult_; } bool isValid () const { return lastResult_.isValid(); } + explicit operator bool() const { return isValid(); } - // can't use lib::BoolCheckable, because tr1::function implements safe-bool too };