Commit 6f97afa7 authored by Morten Hustveit's avatar Morten Hustveit

Prevent accidental bool conversion of AutoCloseFd.

parent bf015f61
......@@ -257,6 +257,10 @@ public:
inline operator int() const { return fd; }
inline int get() const { return fd; }
operator bool() const = delete;
// Deleting this operator prevents accidental use in boolean contexts, which
// the int conversion operator above would otherwise allow.
inline bool operator==(decltype(nullptr)) { return fd < 0; }
inline bool operator!=(decltype(nullptr)) { return fd >= 0; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment