From 3a36e6c51974594d994562c712e068835aae85f1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 27 Oct 2020 01:55:22 +0300 Subject: VS 2013 workarounds --- include/winapi/process.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'include/winapi') diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp index 095b50c..3c9a840 100644 --- a/include/winapi/process.hpp +++ b/include/winapi/process.hpp @@ -29,11 +29,19 @@ struct ProcessParameters { explicit ProcessParameters(const CommandLine& cmd_line) : cmd_line{cmd_line} {} + // VS 2013 won't generate these automatically. + ProcessParameters(ProcessParameters&&) BOOST_NOEXCEPT_OR_NOTHROW; + ProcessParameters& operator=(ProcessParameters) BOOST_NOEXCEPT_OR_NOTHROW; + void swap(ProcessParameters& other) BOOST_NOEXCEPT_OR_NOTHROW; + ProcessParameters(const ProcessParameters&) = delete; + CommandLine cmd_line; boost::optional io; ConsoleCreationMode console_mode = ConsoleNew; }; +void swap(ProcessParameters&, ProcessParameters&) BOOST_NOEXCEPT_OR_NOTHROW; + struct ShellParameters : ProcessParameters { explicit ShellParameters(const CommandLine& cmd_line) : ProcessParameters{cmd_line} {} @@ -43,9 +51,17 @@ struct ShellParameters : ProcessParameters { return params; } + // VS 2013 won't generate these automatically. + ShellParameters(ShellParameters&&) BOOST_NOEXCEPT_OR_NOTHROW; + ShellParameters& operator=(ShellParameters) BOOST_NOEXCEPT_OR_NOTHROW; + void swap(ShellParameters& other) BOOST_NOEXCEPT_OR_NOTHROW; + ShellParameters(const ShellParameters&) = delete; + boost::optional verb; }; +void swap(ShellParameters&, ShellParameters&) BOOST_NOEXCEPT_OR_NOTHROW; + class Process { public: static Process create(ProcessParameters); @@ -55,6 +71,12 @@ public: static Process shell(const ShellParameters&); static Process shell(const CommandLine&); + // VS 2013 won't generate these automatically. + Process(Process&&) BOOST_NOEXCEPT_OR_NOTHROW; + Process& operator=(Process) BOOST_NOEXCEPT_OR_NOTHROW; + void swap(Process& other) BOOST_NOEXCEPT_OR_NOTHROW; + Process(const Process&) = delete; + bool is_running() const; void wait() const; void terminate(int ec = 0) const; @@ -74,4 +96,26 @@ private: Handle m_handle; }; +void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW; + } // namespace winapi + +namespace std { + +template <> +inline void swap(winapi::ProcessParameters& a, + winapi::ProcessParameters& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + +template <> +inline void swap(winapi::ShellParameters& a, winapi::ShellParameters& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + +template <> +inline void swap(winapi::Process& a, winapi::Process& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + +} // namespace std -- cgit v1.2.3