diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-16 10:58:03 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-16 12:00:32 +0300 |
commit | 41a5d654eb037df21e4588ca749048cb4065658e (patch) | |
tree | d12ac134f4a8b642c52121f3ec0c22be46cbfe3d /include/winapi/stream.hpp | |
parent | Process: support pipe redirection (diff) | |
download | winapi-common-41a5d654eb037df21e4588ca749048cb4065658e.tar.gz winapi-common-41a5d654eb037df21e4588ca749048cb4065658e.zip |
VS 2013 workarounds
Diffstat (limited to '')
-rw-r--r-- | include/winapi/stream.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/winapi/stream.hpp b/include/winapi/stream.hpp index cf85508..6b4bc38 100644 --- a/include/winapi/stream.hpp +++ b/include/winapi/stream.hpp @@ -8,6 +8,8 @@ #include "handle.hpp" #include "pipe.hpp" +#include <boost/config.hpp> + #include <string> #include <utility> @@ -18,25 +20,87 @@ struct Stream { Stream(Handle&& handle) : handle{std::move(handle)} {} Handle handle; + + // VS 2013 won't generate these automatically. + + Stream(Stream&& other) BOOST_NOEXCEPT_OR_NOTHROW { swap(other); } + + Stream& operator=(Stream other) BOOST_NOEXCEPT_OR_NOTHROW { + swap(other); + return *this; + } + + void swap(Stream& other) BOOST_NOEXCEPT_OR_NOTHROW { + using std::swap; + swap(handle, other.handle); + } + + Stream(const Stream&) = delete; }; +inline void swap(Stream& a, Stream& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + struct Stdin : Stream { Stdin(); explicit Stdin(const std::string& file); explicit Stdin(Pipe&); + + // VS 2013 won't generate these automatically. + + Stdin(Stdin&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {} + + Stdin& operator=(Stdin other) BOOST_NOEXCEPT_OR_NOTHROW { + Stream::operator=(std::move(other)); + return *this; + } + + Stdin(const Stdin&) = delete; }; struct Stdout : Stream { Stdout(); explicit Stdout(const std::string& file); explicit Stdout(Pipe&); + + // VS 2013 won't generate these automatically. + + Stdout(Stdout&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {} + + Stdout& operator=(Stdout other) BOOST_NOEXCEPT_OR_NOTHROW { + Stream::operator=(std::move(other)); + return *this; + } + + Stdout(const Stdout&) = delete; }; struct Stderr : Stream { Stderr(); explicit Stderr(const std::string& file); explicit Stderr(Pipe&); + + // VS 2013 won't generate these automatically. + + Stderr(Stderr&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {} + + Stderr& operator=(Stderr other) BOOST_NOEXCEPT_OR_NOTHROW { + Stream::operator=(std::move(other)); + return *this; + } + + Stderr(const Stderr&) = delete; }; } // namespace process } // namespace winapi + +namespace std { + +template <> +inline void swap(winapi::process::Stream& a, winapi::process::Stream& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + +} // namespace std |