diff --git a/include/boost/asio/basic_readable_pipe.hpp b/include/boost/asio/basic_readable_pipe.hpp index 27d1fe5a..c000bd3d 100644 --- a/include/boost/asio/basic_readable_pipe.hpp +++ b/include/boost/asio/basic_readable_pipe.hpp @@ -204,6 +204,53 @@ public: impl_ = std::move(other.impl_); return *this; } + + // All pipes have access to each other's implementations. + template + friend class basic_readable_pipe; + + /// Move-construct a basic_readable_pipe from a pipe of another executor type. + /** + * This constructor moves a pipe from one object to another. + * + * @param other The other basic_readable_pipe object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_readable_pipe(const executor_type&) + * constructor. + */ + template + basic_readable_pipe(basic_readable_pipe&& other, + typename constraint< + is_convertible::value, + defaulted_constraint + >::type = defaulted_constraint()) + : impl_(std::move(other.impl_)) + { + } + + /// Move-assign a basic_readable_pipe from a pipe of another executor type. + /** + * This assignment operator moves a pipe from one object to another. + * + * @param other The other basic_readable_pipe object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_readable_pipe(const executor_type&) + * constructor. + */ + template + typename constraint< + is_convertible::value, + basic_readable_pipe& + >::type operator=(basic_readable_pipe&& other) + { + basic_readable_pipe tmp(std::move(other)); + impl_ = std::move(tmp.impl_); + return *this; + } #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the pipe. diff --git a/include/boost/asio/basic_writable_pipe.hpp b/include/boost/asio/basic_writable_pipe.hpp index bb118b4b..1cfe2638 100644 --- a/include/boost/asio/basic_writable_pipe.hpp +++ b/include/boost/asio/basic_writable_pipe.hpp @@ -204,6 +204,53 @@ public: impl_ = std::move(other.impl_); return *this; } + + // All pipes have access to each other's implementations. + template + friend class basic_writable_pipe; + + /// Move-construct a basic_writable_pipe from a pipe of another executor type. + /** + * This constructor moves a pipe from one object to another. + * + * @param other The other basic_writable_pipe object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_writable_pipe(const executor_type&) + * constructor. + */ + template + basic_writable_pipe(basic_writable_pipe&& other, + typename constraint< + is_convertible::value, + defaulted_constraint + >::type = defaulted_constraint()) + : impl_(std::move(other.impl_)) + { + } + + /// Move-assign a basic_writable_pipe from a pipe of another executor type. + /** + * This assignment operator moves a pipe from one object to another. + * + * @param other The other basic_writable_pipe object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_writable_pipe(const executor_type&) + * constructor. + */ + template + typename constraint< + is_convertible::value, + basic_writable_pipe& + >::type operator=(basic_writable_pipe&& other) + { + basic_writable_pipe tmp(std::move(other)); + impl_ = std::move(tmp.impl_); + return *this; + } #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the pipe. diff --git a/test/readable_pipe.cpp b/test/readable_pipe.cpp index 67f1b8a0..897d8f45 100644 --- a/test/readable_pipe.cpp +++ b/test/readable_pipe.cpp @@ -75,6 +75,9 @@ void test() #if defined(BOOST_ASIO_HAS_MOVE) readable_pipe pipe5(std::move(pipe4)); + + basic_readable_pipe pipe6(ioc); + readable_pipe pipe7(std::move(pipe6)); #endif // defined(BOOST_ASIO_HAS_MOVE) // basic_readable_pipe operators. @@ -82,6 +85,7 @@ void test() #if defined(BOOST_ASIO_HAS_MOVE) pipe1 = readable_pipe(ioc); pipe1 = std::move(pipe2); + pipe1 = std::move(pipe6); #endif // defined(BOOST_ASIO_HAS_MOVE) // basic_io_object functions. diff --git a/test/writable_pipe.cpp b/test/writable_pipe.cpp index 87bd6f71..3946c07d 100644 --- a/test/writable_pipe.cpp +++ b/test/writable_pipe.cpp @@ -75,6 +75,9 @@ void test() #if defined(BOOST_ASIO_HAS_MOVE) writable_pipe pipe5(std::move(pipe4)); + + basic_writable_pipe pipe6(ioc); + writable_pipe pipe7(std::move(pipe6)); #endif // defined(BOOST_ASIO_HAS_MOVE) // basic_writable_pipe operators. @@ -82,6 +85,7 @@ void test() #if defined(BOOST_ASIO_HAS_MOVE) pipe1 = writable_pipe(ioc); pipe1 = std::move(pipe2); + pipe1 = std::move(pipe6); #endif // defined(BOOST_ASIO_HAS_MOVE) // basic_io_object functions.