Commit f68ef01515198efacf8e06d08317848e275cec46

Authored by Grzegorz Jabłoński
1 parent 449daace

C++ std cleanup

05-daytime1.cpp
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 // 9 //
10 10
11 #include <iostream> 11 #include <iostream>
12 -#include <boost/array.hpp>  
13 #include <asio.hpp> 12 #include <asio.hpp>
14 13
15 using asio::ip::tcp; 14 using asio::ip::tcp;
@@ -35,7 +34,7 @@ int main(int argc, char* argv[]) @@ -35,7 +34,7 @@ int main(int argc, char* argv[])
35 34
36 for (;;) 35 for (;;)
37 { 36 {
38 - boost::array<char, 128> buf; 37 + std::array<char, 128> buf;
39 asio::error_code error; 38 asio::error_code error;
40 39
41 size_t len = socket.read_some(asio::buffer(buf), error); 40 size_t len = socket.read_some(asio::buffer(buf), error);
07-daytime3.cpp
@@ -11,9 +11,6 @@ @@ -11,9 +11,6 @@
11 #include <ctime> 11 #include <ctime>
12 #include <iostream> 12 #include <iostream>
13 #include <string> 13 #include <string>
14 -#include <boost/bind/bind.hpp>  
15 -#include <boost/shared_ptr.hpp>  
16 -#include <boost/enable_shared_from_this.hpp>  
17 #include <asio.hpp> 14 #include <asio.hpp>
18 15
19 using asio::ip::tcp; 16 using asio::ip::tcp;
@@ -26,10 +23,10 @@ std::string make_daytime_string() @@ -26,10 +23,10 @@ std::string make_daytime_string()
26 } 23 }
27 24
28 class tcp_connection 25 class tcp_connection
29 - : public boost::enable_shared_from_this<tcp_connection> 26 + : public std::enable_shared_from_this<tcp_connection>
30 { 27 {
31 public: 28 public:
32 - typedef boost::shared_ptr<tcp_connection> pointer; 29 + typedef std::shared_ptr<tcp_connection> pointer;
33 30
34 static pointer create(asio::io_context& io_context) 31 static pointer create(asio::io_context& io_context)
35 { 32 {
08-daytime4.cpp
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 // 9 //
10 10
11 #include <iostream> 11 #include <iostream>
12 -#include <boost/array.hpp>  
13 #include <asio.hpp> 12 #include <asio.hpp>
14 13
15 using asio::ip::udp; 14 using asio::ip::udp;
@@ -33,10 +32,10 @@ int main(int argc, char* argv[]) @@ -33,10 +32,10 @@ int main(int argc, char* argv[])
33 udp::socket socket(io_context); 32 udp::socket socket(io_context);
34 socket.open(udp::v4()); 33 socket.open(udp::v4());
35 34
36 - boost::array<char, 1> send_buf = {{ 0 }}; 35 + std::array<char, 1> send_buf = {{ 0 }};
37 socket.send_to(asio::buffer(send_buf), receiver_endpoint); 36 socket.send_to(asio::buffer(send_buf), receiver_endpoint);
38 37
39 - boost::array<char, 128> recv_buf; 38 + std::array<char, 128> recv_buf;
40 udp::endpoint sender_endpoint; 39 udp::endpoint sender_endpoint;
41 size_t len = socket.receive_from( 40 size_t len = socket.receive_from(
42 asio::buffer(recv_buf), sender_endpoint); 41 asio::buffer(recv_buf), sender_endpoint);
09-daytime5.cpp
@@ -11,7 +11,6 @@ @@ -11,7 +11,6 @@
11 #include <ctime> 11 #include <ctime>
12 #include <iostream> 12 #include <iostream>
13 #include <string> 13 #include <string>
14 -#include <boost/array.hpp>  
15 #include <asio.hpp> 14 #include <asio.hpp>
16 15
17 using asio::ip::udp; 16 using asio::ip::udp;
@@ -33,7 +32,7 @@ int main() @@ -33,7 +32,7 @@ int main()
33 32
34 for (;;) 33 for (;;)
35 { 34 {
36 - boost::array<char, 1> recv_buf; 35 + std::array<char, 1> recv_buf;
37 udp::endpoint remote_endpoint; 36 udp::endpoint remote_endpoint;
38 socket.receive_from(asio::buffer(recv_buf), remote_endpoint); 37 socket.receive_from(asio::buffer(recv_buf), remote_endpoint);
39 38
10-daytime6.cpp
@@ -11,9 +11,6 @@ @@ -11,9 +11,6 @@
11 #include <ctime> 11 #include <ctime>
12 #include <iostream> 12 #include <iostream>
13 #include <string> 13 #include <string>
14 -#include <boost/array.hpp>  
15 -#include <boost/bind/bind.hpp>  
16 -#include <boost/shared_ptr.hpp>  
17 #include <asio.hpp> 14 #include <asio.hpp>
18 15
19 using asio::ip::udp; 16 using asio::ip::udp;
@@ -49,7 +46,7 @@ private: @@ -49,7 +46,7 @@ private:
49 { 46 {
50 if (!error) 47 if (!error)
51 { 48 {
52 - boost::shared_ptr<std::string> message( 49 + std::shared_ptr<std::string> message(
53 new std::string(make_daytime_string())); 50 new std::string(make_daytime_string()));
54 51
55 socket_.async_send_to(asio::buffer(*message), remote_endpoint_, 52 socket_.async_send_to(asio::buffer(*message), remote_endpoint_,
@@ -61,7 +58,7 @@ private: @@ -61,7 +58,7 @@ private:
61 } 58 }
62 } 59 }
63 60
64 - void handle_send(boost::shared_ptr<std::string> /*message*/, 61 + void handle_send(std::shared_ptr<std::string> /*message*/,
65 const asio::error_code& /*error*/, 62 const asio::error_code& /*error*/,
66 std::size_t /*bytes_transferred*/) 63 std::size_t /*bytes_transferred*/)
67 { 64 {
@@ -69,7 +66,7 @@ private: @@ -69,7 +66,7 @@ private:
69 66
70 udp::socket socket_; 67 udp::socket socket_;
71 udp::endpoint remote_endpoint_; 68 udp::endpoint remote_endpoint_;
72 - boost::array<char, 1> recv_buffer_; 69 + std::array<char, 1> recv_buffer_;
73 }; 70 };
74 71
75 int main() 72 int main()
11-daytime7.cpp
@@ -11,10 +11,6 @@ @@ -11,10 +11,6 @@
11 #include <ctime> 11 #include <ctime>
12 #include <iostream> 12 #include <iostream>
13 #include <string> 13 #include <string>
14 -#include <boost/array.hpp>  
15 -#include <boost/bind/bind.hpp>  
16 -#include <boost/shared_ptr.hpp>  
17 -#include <boost/enable_shared_from_this.hpp>  
18 #include <asio.hpp> 14 #include <asio.hpp>
19 15
20 using asio::ip::tcp; 16 using asio::ip::tcp;
@@ -28,10 +24,10 @@ std::string make_daytime_string() @@ -28,10 +24,10 @@ std::string make_daytime_string()
28 } 24 }
29 25
30 class tcp_connection 26 class tcp_connection
31 - : public boost::enable_shared_from_this<tcp_connection> 27 + : public std::enable_shared_from_this<tcp_connection>
32 { 28 {
33 public: 29 public:
34 - typedef boost::shared_ptr<tcp_connection> pointer; 30 + typedef std::shared_ptr<tcp_connection> pointer;
35 31
36 static pointer create(asio::io_context& io_context) 32 static pointer create(asio::io_context& io_context)
37 { 33 {
@@ -48,7 +44,7 @@ public: @@ -48,7 +44,7 @@ public:
48 message_ = make_daytime_string(); 44 message_ = make_daytime_string();
49 45
50 asio::async_write(socket_, asio::buffer(message_), 46 asio::async_write(socket_, asio::buffer(message_),
51 - boost::bind(&tcp_connection::handle_write, shared_from_this())); 47 + std::bind(&tcp_connection::handle_write, shared_from_this()));
52 } 48 }
53 49
54 private: 50 private:
@@ -123,23 +119,23 @@ private: @@ -123,23 +119,23 @@ private:
123 { 119 {
124 if (!error) 120 if (!error)
125 { 121 {
126 - boost::shared_ptr<std::string> message( 122 + std::shared_ptr<std::string> message(
127 new std::string(make_daytime_string())); 123 new std::string(make_daytime_string()));
128 124
129 socket_.async_send_to(asio::buffer(*message), remote_endpoint_, 125 socket_.async_send_to(asio::buffer(*message), remote_endpoint_,
130 - boost::bind(&udp_server::handle_send, this, message)); 126 + std::bind(&udp_server::handle_send, this, message));
131 127
132 start_receive(); 128 start_receive();
133 } 129 }
134 } 130 }
135 131
136 - void handle_send(boost::shared_ptr<std::string> /*message*/) 132 + void handle_send(std::shared_ptr<std::string> /*message*/)
137 { 133 {
138 } 134 }
139 135
140 udp::socket socket_; 136 udp::socket socket_;
141 udp::endpoint remote_endpoint_; 137 udp::endpoint remote_endpoint_;
142 - boost::array<char, 1> recv_buffer_; 138 + std::array<char, 1> recv_buffer_;
143 }; 139 };
144 140
145 int main() 141 int main()