]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/handle.h
Mark boolean conversion operators as explicit
[libs/core.git] / source / io / handle.h
index 8a9db50b60ec5e85032fa5e1eb0741f9857cbdfe..561d710e457e77c73e7766f23d5bfd77f9b82310 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MSP_IO_HANDLE_H_
 #define MSP_IO_HANDLE_H_
 
+#include <cstddef>
+
 namespace Msp {
 namespace IO {
 
@@ -10,7 +12,7 @@ public:
        struct Private;
 
 private:
-       Private *priv;
+       Private *priv = 0;
 
 public:
        Handle();
@@ -21,16 +23,14 @@ public:
        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;
 };
 
 
 void sys_set_blocking(Handle &, bool);
-unsigned sys_read(Handle &, char *, unsigned);
-unsigned sys_write(Handle &, const char *, unsigned);
+void sys_set_inherit(Handle &, bool);
+std::size_t sys_read(Handle &, char *, std::size_t);
+std::size_t sys_write(Handle &, const char *, std::size_t);
 void sys_close(Handle &);
 
 } // namespace IO