Skip to content

Commit ebe6cd7

Browse files
committed
Enable move support for Microsoft Visual C++ 2012.
1 parent 51bba37 commit ebe6cd7

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

asio/include/asio/detail/config.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
9898
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
9999
# endif // defined(__GNUC__)
100+
# if defined(ASIO_MSVC)
101+
# if (_MSC_VER >= 1700)
102+
# define ASIO_HAS_MOVE 1
103+
# endif // (_MSC_VER >= 1700)
104+
# endif // defined(ASIO_MSVC)
100105
# endif // !defined(ASIO_DISABLE_MOVE)
101106
#endif // !defined(ASIO_HAS_MOVE)
102107

asio/include/asio/detail/win_iocp_socket_service.hpp

+18
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ class win_iocp_socket_service : public win_iocp_socket_service_base
165165
other_impl.remote_endpoint_ = endpoint_type();
166166
}
167167

168+
// Move-construct a new socket implementation from another protocol type.
169+
template <typename Protocol1>
170+
void converting_move_construct(implementation_type& impl,
171+
typename win_iocp_socket_service<
172+
Protocol1>::implementation_type& other_impl)
173+
{
174+
this->base_move_construct(impl, other_impl);
175+
176+
impl.protocol_ = protocol_type(other_impl.protocol_);
177+
other_impl.protocol_ = typename Protocol1::endpoint().protocol();
178+
179+
impl.have_remote_endpoint_ = other_impl.have_remote_endpoint_;
180+
other_impl.have_remote_endpoint_ = false;
181+
182+
impl.remote_endpoint_ = other_impl.remote_endpoint_;
183+
other_impl.remote_endpoint_ = typename Protocol1::endpoint();
184+
}
185+
168186
// Open a new socket implementation.
169187
asio::error_code open(implementation_type& impl,
170188
const protocol_type& protocol, asio::error_code& ec)

asio/src/tests/unit/generic/datagram_protocol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ void test()
7979

8080
#if defined(ASIO_HAS_MOVE)
8181
dp::socket socket5(std::move(socket4));
82-
dp::socket socket6(asio::ip::udp::socket(ios));
82+
asio::ip::udp::socket udp_socket(ios);
83+
dp::socket socket6(std::move(udp_socket));
8384
#endif // defined(ASIO_HAS_MOVE)
8485

8586
// basic_datagram_socket operators.

asio/src/tests/unit/generic/raw_protocol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ void test()
7979

8080
#if defined(ASIO_HAS_MOVE)
8181
rp::socket socket5(std::move(socket4));
82-
rp::socket socket6(asio::ip::icmp::socket(ios));
82+
asio::ip::icmp::socket icmp_socket(ios);
83+
rp::socket socket6(std::move(icmp_socket));
8384
#endif // defined(ASIO_HAS_MOVE)
8485

8586
// basic_datagram_socket operators.

asio/src/tests/unit/generic/stream_protocol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ void test()
8989

9090
#if defined(ASIO_HAS_MOVE)
9191
sp::socket socket5(std::move(socket4));
92-
sp::socket socket6(asio::ip::tcp::socket(ios));
92+
asio::ip::tcp::socket tcp_socket(ios);
93+
sp::socket socket6(std::move(tcp_socket));
9394
#endif // defined(ASIO_HAS_MOVE)
9495

9596
// basic_stream_socket operators.

asio/src/tests/unit/ip/tcp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void test()
203203
#endif // !defined(ASIO_WINDOWS_RUNTIME)
204204

205205
#if defined(ASIO_HAS_MOVE)
206-
ip::tcp::socket socket7(std::move(socket6));
206+
ip::tcp::socket socket7(std::move(socket5));
207207
#endif // defined(ASIO_HAS_MOVE)
208208

209209
// basic_stream_socket operators.
@@ -662,7 +662,7 @@ void test()
662662
#endif // !defined(ASIO_WINDOWS_RUNTIME)
663663

664664
#if defined(ASIO_HAS_MOVE)
665-
ip::tcp::acceptor acceptor7(std::move(acceptor6));
665+
ip::tcp::acceptor acceptor7(std::move(acceptor5));
666666
#endif // defined(ASIO_HAS_MOVE)
667667

668668
// basic_socket_acceptor operators.

0 commit comments

Comments
 (0)