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