Also turn const void * operators into actual boolean conversions.
delete priv;
}
-Handle::operator const void *() const
+Handle::operator bool() const
{
- return priv->handle!=INVALID_HANDLE_VALUE ? this : 0;
+ return priv->handle!=INVALID_HANDLE_VALUE;
}
Private &operator*() { return *priv; }
const Private &operator*() const { return *priv; }
- /** This is effectively a boolean conversion, but avoids accidental
- conversion to OS native handles. Unix-based systems use int and win32 uses
- void *; const void * is not implicitly convertible to either. */
- operator const void *() const;
+ explicit operator bool() const;
};
unsigned short ku = 0;
unsigned short ten = 0;
- operator bool() { return ku!=0 && ten!=0; }
+ explicit operator bool() { return ku!=0 && ten!=0; }
};
unichar jisx0208_to_ucs(Kuten);
size_type length; //< Length of the match (end-begin)
std::string str; //< The part of the string that matched
- operator bool() const { return match; }
+ explicit operator bool() const { return match; }
};
private:
/** Shorthand for the group() function. */
const Group &operator[](unsigned i) const { return group(i); }
- operator bool() const { return !empty(); }
+ explicit operator bool() const { return !empty(); }
};
} // namespace Msp
bool operator==(const TimeDelta &t) const { return usec==t.usec; }
bool operator!=(const TimeDelta &t) const { return usec!=t.usec; }
- operator const void *() const { return usec ? this : 0; }
+ explicit operator bool() const { return usec; }
};
template<typename T>
bool operator==(const TimeStamp &t) const { return usec==t.usec; }
bool operator!=(const TimeStamp &t) const { return usec!=t.usec; }
- operator const void *() const { return usec>0 ? this : 0; }
+ explicit operator bool() const { return usec>0; }
static TimeStamp from_unixtime(time_t t) { return TimeStamp(t*1000000LL); }
};