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

Make AutoCloseFd stringifiable (broken by operator bool deletion).

parent 3ce6f4af
...@@ -54,5 +54,13 @@ TEST(Io, WriteVec) { ...@@ -54,5 +54,13 @@ TEST(Io, WriteVec) {
EXPECT_STREQ("foobar", buf); EXPECT_STREQ("foobar", buf);
} }
KJ_TEST("stringify AutoCloseFd") {
int fds[2];
miniposix::pipe(fds);
AutoCloseFd in(fds[0]), out(fds[1]);
KJ_EXPECT(kj::str(in) == kj::str(fds[0]), in, fds[0]);
}
} // namespace } // namespace
} // namespace kj } // namespace kj
...@@ -269,6 +269,11 @@ private: ...@@ -269,6 +269,11 @@ private:
UnwindDetector unwindDetector; UnwindDetector unwindDetector;
}; };
inline auto KJ_STRINGIFY(const AutoCloseFd& fd)
-> decltype(kj::toCharSequence(implicitCast<int>(fd))) {
return kj::toCharSequence(implicitCast<int>(fd));
}
class FdInputStream: public InputStream { class FdInputStream: public InputStream {
// An InputStream wrapping a file descriptor. // An InputStream wrapping a file descriptor.
......
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