Skip to content

Commit f1ae7a0

Browse files
committed
better constructor visibility control
1 parent ad0cd77 commit f1ae7a0

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/internal/sio_client_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ namespace sio {
433433
}
434434
else
435435
{
436-
std::pair<const std::string, socket::ptr> p(aux,std::make_shared<sio::socket>(this,aux));
436+
std::pair<const std::string, socket::ptr> p(aux,std::shared_ptr<sio::socket>(new sio::socket(this,aux)));
437437
return (m_sockets.insert(p).first)->second;
438438
}
439439
}

src/sio_client.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ namespace sio {
5656
std::string const& get_sessionid() const;
5757

5858
private:
59+
//disable copy constructor and assign operator.
60+
client(client const& cl){}
61+
void operator=(client const& cl){}
62+
5963
client_impl* m_impl;
6064
};
6165

src/sio_socket.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ namespace sio
5252

5353
typedef std::shared_ptr<socket> ptr;
5454

55-
socket(client_impl*,std::string const&);
56-
5755
~socket();
5856

5957
void on(std::string const& event_name,event_listener const& func);
@@ -88,6 +86,8 @@ namespace sio
8886
std::string const& get_namespace() const;
8987

9088
protected:
89+
socket(client_impl*,std::string const&);
90+
9191
void on_connected();
9292

9393
void on_close();
@@ -99,6 +99,10 @@ namespace sio
9999
friend class client_impl;
100100

101101
private:
102+
//disable copy constructor and assign operator.
103+
socket(socket const& sock){}
104+
void operator=(socket const& sock){}
105+
102106
class impl;
103107
impl *m_impl;
104108
};

0 commit comments

Comments
 (0)