From 9ae4ea68826e58a07aeb67b560f9484b56715325 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 10 Sep 2018 15:06:49 +0200 Subject: [PATCH] STYLE: operator bool conversion for IOstream (issue #1001) - replaces previous pointer conversion --- src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H index 08baec0a282..318487b663f 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H @@ -181,12 +181,12 @@ public: // Check - //- Check IOstream status for given operation - // print IOstream state if error has occured + //- Check IOstream status for given operation. + // Print IOstream state if error has occurred virtual bool check(const char* operation) const; - //- Check IOstream status for given operation - // print IOstream state if error has occured and exit + //- Check IOstream status for given operation. + // Print IOstream state if error has occurred and exit void fatalCheck(const char* operation) const; //- Return true if stream has been opened @@ -225,12 +225,10 @@ public: return ioState_ & ios_base::badbit; } - //- Return non-zero if the stream has not failed - operator void*() const + //- Return true if the stream has not failed + explicit operator bool() const { - return fail() - ? reinterpret_cast<void*>(0) - : reinterpret_cast<void*>(-1); + return !fail(); } //- Return true if the stream has failed -- GitLab