]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/socket.h
Use std::unique_ptr for owning pointers
[libs/net.git] / source / net / socket.h
index c55a5390a673d868b51d9e52a9675fee18f79b79..7a47793eab9515f9871446c03c5cc612753c6fa7 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_NET_SOCKET_H_
 #define MSP_NET_SOCKET_H_
 
+#include <memory>
 #include <msp/core/except.h>
 #include <msp/io/eventobject.h>
 #include <msp/io/handle.h>
@@ -30,8 +31,8 @@ protected:
 
        struct Private;
 
-       Private *priv = nullptr;
-       SockAddr *local_addr = nullptr;
+       std::unique_ptr<Private> priv;
+       std::unique_ptr<SockAddr> local_addr;
 
        Socket(const Private &);
        Socket(Family, int, int);
@@ -50,7 +51,7 @@ public:
        users of the address. */
        void bind(const SockAddr &);
 
-       bool is_bound() const { return local_addr; }
+       bool is_bound() const { return static_cast<bool>(local_addr); }
        const SockAddr &get_local_address() const;
 
        void set_timeout(const Time::TimeDelta &);