Commit 3ce6f4af authored by Kenton Varda's avatar Kenton Varda

Merge pull request #166 from mortehu/master

Prevent accidental bool conversion of AutoCloseFd.
parents 50d356a0 6f97afa7
......@@ -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