aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-27 13:17:26 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-27 13:18:45 +0300
commit0c62070b24273e565cce112ab061df6665d3ae8c (patch)
treea9a36ef593871daef57986fbfbbfb44de8c1116d
parentBoost.Test is broken in 1.62 (diff)
downloadwinapi-common-0c62070b24273e565cce112ab061df6665d3ae8c.tar.gz
winapi-common-0c62070b24273e565cce112ab061df6665d3ae8c.zip
code style
Don't use brace initialization in constructors, VS 2013 doesn't like that.
-rw-r--r--include/winapi/file.hpp4
-rw-r--r--include/winapi/handle.hpp4
-rw-r--r--include/winapi/pipe.hpp23
-rw-r--r--include/winapi/process.hpp20
-rw-r--r--include/winapi/process_io.hpp24
-rw-r--r--include/winapi/resource.hpp2
-rw-r--r--include/winapi/shmem.hpp29
-rw-r--r--src/handle.cpp2
-rw-r--r--src/pipe.cpp16
-rw-r--r--src/process.cpp50
-rw-r--r--src/process_io.cpp46
-rw-r--r--test/unit_tests/fixtures.hpp4
-rw-r--r--test/unit_tests/shared/command.hpp21
-rw-r--r--test/unit_tests/shared/console.hpp4
-rw-r--r--test/unit_tests/shared/fixed_size.hpp2
-rw-r--r--test/unit_tests/shared/worker.hpp33
16 files changed, 167 insertions, 117 deletions
diff --git a/include/winapi/file.hpp b/include/winapi/file.hpp
index 3dcd0d1..b9688e9 100644
--- a/include/winapi/file.hpp
+++ b/include/winapi/file.hpp
@@ -15,8 +15,6 @@ namespace winapi {
class File : private Handle {
public:
- explicit File(Handle&& handle) : Handle{std::move(handle)} {}
-
static Handle open_r(const std::string&);
static Handle open_r(const CanonicalPath&);
static Handle open_w(const std::string&);
@@ -25,6 +23,8 @@ public:
static void remove(const std::string&);
static void remove(const CanonicalPath&);
+ explicit File(Handle&& handle) : Handle(std::move(handle)) {}
+
using Handle::close;
using Handle::read;
diff --git a/include/winapi/handle.hpp b/include/winapi/handle.hpp
index 7c10735..cd114d5 100644
--- a/include/winapi/handle.hpp
+++ b/include/winapi/handle.hpp
@@ -25,8 +25,8 @@ public:
Handle(Handle&& other) BOOST_NOEXCEPT_OR_NOTHROW;
Handle& operator=(Handle other) BOOST_NOEXCEPT_OR_NOTHROW;
-
void swap(Handle& other) BOOST_NOEXCEPT_OR_NOTHROW;
+ Handle(const Handle&) = delete;
HANDLE get() const { return m_impl.get(); }
HANDLE ptr() const { return get(); }
@@ -65,8 +65,6 @@ private:
};
std::unique_ptr<void, Close> m_impl;
-
- Handle(const Handle&) = delete;
};
inline void swap(Handle& a, Handle& b) BOOST_NOEXCEPT_OR_NOTHROW {
diff --git a/include/winapi/pipe.hpp b/include/winapi/pipe.hpp
index ebd99e8..9f71858 100644
--- a/include/winapi/pipe.hpp
+++ b/include/winapi/pipe.hpp
@@ -7,12 +7,22 @@
#include "handle.hpp"
+#include <boost/config.hpp>
+
+#include <utility>
+
namespace winapi {
class Pipe {
public:
Pipe();
+ // VS 2013 won't generate these automatically.
+ Pipe(Pipe&&) BOOST_NOEXCEPT_OR_NOTHROW;
+ Pipe& operator=(Pipe) BOOST_NOEXCEPT_OR_NOTHROW;
+ void swap(Pipe&) BOOST_NOEXCEPT_OR_NOTHROW;
+ Pipe(const Pipe&) = delete;
+
Handle& read_end() { return m_read_end; }
const Handle& read_end() const { return m_read_end; }
Handle& write_end() { return m_write_end; }
@@ -23,4 +33,17 @@ private:
Handle m_write_end;
};
+inline void swap(Pipe& a, Pipe& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
} // namespace winapi
+
+namespace std {
+
+template <>
+inline void swap(winapi::Pipe& a, winapi::Pipe& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+} // namespace std
diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp
index 3c9a840..db5f5d1 100644
--- a/include/winapi/process.hpp
+++ b/include/winapi/process.hpp
@@ -27,7 +27,7 @@ struct ProcessParameters {
ConsoleNew,
};
- explicit ProcessParameters(const CommandLine& cmd_line) : cmd_line{cmd_line} {}
+ explicit ProcessParameters(const CommandLine& cmd_line) : cmd_line(cmd_line) {}
// VS 2013 won't generate these automatically.
ProcessParameters(ProcessParameters&&) BOOST_NOEXCEPT_OR_NOTHROW;
@@ -40,17 +40,19 @@ struct ProcessParameters {
ConsoleCreationMode console_mode = ConsoleNew;
};
-void swap(ProcessParameters&, ProcessParameters&) BOOST_NOEXCEPT_OR_NOTHROW;
+inline void swap(ProcessParameters& a, ProcessParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
struct ShellParameters : ProcessParameters {
- explicit ShellParameters(const CommandLine& cmd_line) : ProcessParameters{cmd_line} {}
-
static ShellParameters runas(const CommandLine& cmd_line) {
ShellParameters params{cmd_line};
params.verb = "runas";
return params;
}
+ explicit ShellParameters(const CommandLine& cmd_line) : ProcessParameters(cmd_line) {}
+
// VS 2013 won't generate these automatically.
ShellParameters(ShellParameters&&) BOOST_NOEXCEPT_OR_NOTHROW;
ShellParameters& operator=(ShellParameters) BOOST_NOEXCEPT_OR_NOTHROW;
@@ -60,7 +62,9 @@ struct ShellParameters : ProcessParameters {
boost::optional<std::string> verb;
};
-void swap(ShellParameters&, ShellParameters&) BOOST_NOEXCEPT_OR_NOTHROW;
+inline void swap(ShellParameters& a, ShellParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
class Process {
public:
@@ -89,14 +93,16 @@ public:
static std::string get_resource_string(unsigned int id);
private:
- explicit Process(Handle&& handle) : m_handle{std::move(handle)} {}
+ explicit Process(Handle&& handle) : m_handle(std::move(handle)) {}
static HMODULE get_exe_module();
Handle m_handle;
};
-void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW;
+inline void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
} // namespace winapi
diff --git a/include/winapi/process_io.hpp b/include/winapi/process_io.hpp
index 512cb7b..976ad6e 100644
--- a/include/winapi/process_io.hpp
+++ b/include/winapi/process_io.hpp
@@ -20,16 +20,18 @@ namespace process {
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;
Stream& operator=(Stream other) BOOST_NOEXCEPT_OR_NOTHROW;
void swap(Stream& other) BOOST_NOEXCEPT_OR_NOTHROW;
Stream(const Stream&) = delete;
+
+ Handle handle;
};
-void swap(Stream& a, Stream& b) BOOST_NOEXCEPT_OR_NOTHROW;
+inline void swap(Stream& a, Stream& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
struct Stdin : Stream {
Stdin();
@@ -70,20 +72,22 @@ struct Stderr : Stream {
struct IO {
IO() = default;
- void close();
-
- Stdin std_in;
- Stdout std_out;
- Stderr std_err;
-
// VS 2013 won't generate these automatically.
IO(IO&& other) BOOST_NOEXCEPT_OR_NOTHROW;
IO& operator=(IO other) BOOST_NOEXCEPT_OR_NOTHROW;
void swap(IO& other) BOOST_NOEXCEPT_OR_NOTHROW;
IO(const IO&) = delete;
+
+ void close();
+
+ Stdin std_in;
+ Stdout std_out;
+ Stderr std_err;
};
-void swap(IO& a, IO& b) BOOST_NOEXCEPT_OR_NOTHROW;
+inline void swap(IO& a, IO& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
} // namespace process
} // namespace winapi
diff --git a/include/winapi/resource.hpp b/include/winapi/resource.hpp
index 2f77d3e..3fda73e 100644
--- a/include/winapi/resource.hpp
+++ b/include/winapi/resource.hpp
@@ -16,7 +16,7 @@ struct Resource {
Resource() = default;
- Resource(const void* data, std::size_t nb) : data{data}, nb{nb} {}
+ Resource(const void* data, std::size_t nb) : data(data), nb(nb) {}
Buffer copy() const { return {data, nb}; }
diff --git a/include/winapi/shmem.hpp b/include/winapi/shmem.hpp
index 0fb2b76..f2ce33e 100644
--- a/include/winapi/shmem.hpp
+++ b/include/winapi/shmem.hpp
@@ -38,7 +38,7 @@ private:
SharedMemory() = default;
- SharedMemory(Handle&& handle, void* addr) : m_handle{std::move(handle)}, m_addr{addr} {}
+ SharedMemory(Handle&& handle, void* addr) : m_handle(std::move(handle)), m_addr(addr) {}
Handle m_handle;
std::unique_ptr<void, Unmap> m_addr;
@@ -67,26 +67,28 @@ public:
}
SharedObject(SharedObject&& other) BOOST_NOEXCEPT_OR_NOTHROW
- : m_shmem{std::move(other.m_shmem)},
- m_destruct{other.m_destruct} {}
+ : m_shmem(std::move(other.m_shmem)),
+ m_destruct(other.m_destruct) {}
SharedObject& operator=(SharedObject other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(other);
return *this;
}
- ~SharedObject() {
- if (m_destruct && ptr()) {
- ptr()->~T();
- }
- }
-
void swap(SharedObject& other) BOOST_NOEXCEPT_OR_NOTHROW {
using std::swap;
swap(m_shmem, other.m_shmem);
swap(m_destruct, other.m_destruct);
}
+ SharedObject(const SharedObject&) = delete;
+
+ ~SharedObject() {
+ if (m_destruct && ptr()) {
+ ptr()->~T();
+ }
+ }
+
T* ptr() const { return reinterpret_cast<T*>(m_shmem.ptr()); }
T& get() const { return *ptr(); }
@@ -94,13 +96,11 @@ public:
T& operator*() const { return get(); }
private:
- explicit SharedObject(SharedMemory&& shmem) : m_shmem{std::move(shmem)} {}
+ explicit SharedObject(SharedMemory&& shmem) : m_shmem(std::move(shmem)) {}
SharedMemory m_shmem;
// Destruct only once, no matter the number of mappings.
bool m_destruct = false;
-
- SharedObject(const SharedObject&) = delete;
};
template <typename T>
@@ -117,9 +117,4 @@ inline void swap(winapi::SharedMemory& a, winapi::SharedMemory& b) BOOST_NOEXCEP
a.swap(b);
}
-template <typename T>
-inline void swap(winapi::SharedObject<T>& a, winapi::SharedObject<T>& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
-}
-
} // namespace std
diff --git a/src/handle.cpp b/src/handle.cpp
index fa3d8c0..4678519 100644
--- a/src/handle.cpp
+++ b/src/handle.cpp
@@ -35,7 +35,7 @@ bool is_std_handle(HANDLE handle) {
} // namespace
-Handle::Handle(HANDLE impl) : m_impl{impl} {}
+Handle::Handle(HANDLE impl) : m_impl(impl) {}
Handle::Handle(Handle&& other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(other);
diff --git a/src/pipe.cpp b/src/pipe.cpp
index f809995..299ab0f 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -12,6 +12,7 @@
#include <windows.h>
#include <cstring>
+#include <utility>
namespace winapi {
namespace {
@@ -43,4 +44,19 @@ Pipe::Pipe() {
create_pipe(m_read_end, m_write_end);
}
+Pipe::Pipe(Pipe&& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+}
+
+Pipe& Pipe::operator=(Pipe other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+}
+
+void Pipe::swap(Pipe& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ swap(m_read_end, other.m_read_end);
+ swap(m_write_end, other.m_write_end);
+}
+
} // namespace winapi
diff --git a/src/process.cpp b/src/process.cpp
index 2fe6f4b..bac8bb8 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -161,9 +161,9 @@ Handle shell_execute(const ShellParameters& params) {
} // namespace
ProcessParameters::ProcessParameters(ProcessParameters&& other) BOOST_NOEXCEPT_OR_NOTHROW
- : cmd_line{std::move(other.cmd_line)},
- io{std::move(other.io)},
- console_mode{std::move(other.console_mode)} {}
+ : cmd_line(std::move(other.cmd_line)),
+ io(std::move(other.io)),
+ console_mode(std::move(other.console_mode)) {}
ProcessParameters& ProcessParameters::operator=(ProcessParameters other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(other);
@@ -177,13 +177,9 @@ void ProcessParameters::swap(ProcessParameters& other) BOOST_NOEXCEPT_OR_NOTHROW
swap(console_mode, other.console_mode);
}
-void swap(ProcessParameters& a, ProcessParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
-}
-
ShellParameters::ShellParameters(ShellParameters&& other) BOOST_NOEXCEPT_OR_NOTHROW
- : ProcessParameters{std::move(other)},
- verb{std::move(verb)} {}
+ : ProcessParameters(std::move(other)),
+ verb(std::move(verb)) {}
ShellParameters& ShellParameters::operator=(ShellParameters other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(other);
@@ -196,28 +192,6 @@ void ShellParameters::swap(ShellParameters& other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(verb, other.verb);
}
-void swap(ShellParameters& a, ShellParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
-}
-
-Process::Process(Process&& other) BOOST_NOEXCEPT_OR_NOTHROW {
- swap(other);
-}
-
-Process& Process::operator=(Process other) BOOST_NOEXCEPT_OR_NOTHROW {
- swap(other);
- return *this;
-}
-
-void Process::swap(Process& other) BOOST_NOEXCEPT_OR_NOTHROW {
- using std::swap;
- swap(m_handle, other.m_handle);
-}
-
-void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
-}
-
Process Process::create(ProcessParameters params) {
return Process{create_process(params)};
}
@@ -242,6 +216,20 @@ Process Process::shell(const CommandLine& cmd_line) {
return shell(params);
}
+Process::Process(Process&& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+}
+
+Process& Process::operator=(Process other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+}
+
+void Process::swap(Process& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ swap(m_handle, other.m_handle);
+}
+
bool Process::is_running() const {
const auto ret = ::WaitForSingleObject(static_cast<HANDLE>(m_handle), 0);
diff --git a/src/process_io.cpp b/src/process_io.cpp
index ec7dbc9..e18558c 100644
--- a/src/process_io.cpp
+++ b/src/process_io.cpp
@@ -16,33 +16,33 @@
namespace winapi {
namespace process {
-Stdin::Stdin() : Stream{Handle::std_in()} {}
+Stdin::Stdin() : Stream(Handle::std_in()) {}
-Stdout::Stdout() : Stream{Handle::std_out()} {}
+Stdout::Stdout() : Stream(Handle::std_out()) {}
-Stderr::Stderr() : Stream{Handle::std_err()} {}
+Stderr::Stderr() : Stream(Handle::std_err()) {}
-Stdin::Stdin(const std::string& path) : Stream{File::open_r(path)} {}
+Stdin::Stdin(const std::string& path) : Stream(File::open_r(path)) {}
-Stdin::Stdin(const CanonicalPath& path) : Stream{File::open_r(path)} {}
+Stdin::Stdin(const CanonicalPath& path) : Stream(File::open_r(path)) {}
-Stdout::Stdout(const std::string& path) : Stream{File::open_w(path)} {}
+Stdout::Stdout(const std::string& path) : Stream(File::open_w(path)) {}
-Stdout::Stdout(const CanonicalPath& path) : Stream{File::open_w(path)} {}
+Stdout::Stdout(const CanonicalPath& path) : Stream(File::open_w(path)) {}
-Stderr::Stderr(const std::string& path) : Stream{File::open_w(path)} {}
+Stderr::Stderr(const std::string& path) : Stream(File::open_w(path)) {}
-Stderr::Stderr(const CanonicalPath& path) : Stream{File::open_w(path)} {}
+Stderr::Stderr(const CanonicalPath& path) : Stream(File::open_w(path)) {}
-Stdin::Stdin(Pipe& pipe) : Stream{std::move(pipe.read_end())} {
+Stdin::Stdin(Pipe& pipe) : Stream(std::move(pipe.read_end())) {
pipe.write_end().dont_inherit();
}
-Stdout::Stdout(Pipe& pipe) : Stream{std::move(pipe.write_end())} {
+Stdout::Stdout(Pipe& pipe) : Stream(std::move(pipe.write_end())) {
pipe.read_end().dont_inherit();
}
-Stderr::Stderr(Pipe& pipe) : Stream{std::move(pipe.write_end())} {
+Stderr::Stderr(Pipe& pipe) : Stream(std::move(pipe.write_end())) {
pipe.read_end().dont_inherit();
}
@@ -60,37 +60,27 @@ void Stream::swap(Stream& other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(handle, other.handle);
}
-void swap(Stream& a, Stream& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
-}
-
-Stdin::Stdin(Stdin&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {}
+Stdin::Stdin(Stdin&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {}
Stdin& Stdin::operator=(Stdin other) BOOST_NOEXCEPT_OR_NOTHROW {
Stream::operator=(std::move(other));
return *this;
}
-Stdout::Stdout(Stdout&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {}
+Stdout::Stdout(Stdout&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {}
Stdout& Stdout::operator=(Stdout other) BOOST_NOEXCEPT_OR_NOTHROW {
Stream::operator=(std::move(other));
return *this;
}
-Stderr::Stderr(Stderr&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream{std::move(other)} {}
+Stderr::Stderr(Stderr&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {}
Stderr& Stderr::operator=(Stderr other) BOOST_NOEXCEPT_OR_NOTHROW {
Stream::operator=(std::move(other));
return *this;
}
-void IO::close() {
- std_in.handle.close();
- std_out.handle.close();
- std_err.handle.close();
-}
-
IO::IO(IO&& other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(other);
}
@@ -107,8 +97,10 @@ void IO::swap(IO& other) BOOST_NOEXCEPT_OR_NOTHROW {
swap(std_err, other.std_err);
}
-void swap(IO& a, IO& b) BOOST_NOEXCEPT_OR_NOTHROW {
- a.swap(b);
+void IO::close() {
+ std_in.handle.close();
+ std_out.handle.close();
+ std_err.handle.close();
}
} // namespace process
diff --git a/test/unit_tests/fixtures.hpp b/test/unit_tests/fixtures.hpp
index aaf6571..011fb75 100644
--- a/test/unit_tests/fixtures.hpp
+++ b/test/unit_tests/fixtures.hpp
@@ -59,14 +59,14 @@ private:
class WithEchoExe : public WithParam {
public:
- WithEchoExe() : WithParam{"--echo_exe="} {}
+ WithEchoExe() : WithParam("--echo_exe=") {}
const std::string& get_echo_exe() { return get_value(); }
};
class WithWorkerExe : public WithParam {
public:
- WithWorkerExe() : WithParam{"--worker_exe="}, m_cmd{worker::Command::create()} {}
+ WithWorkerExe() : WithParam("--worker_exe="), m_cmd(worker::Command::create()) {}
const std::string& get_worker_exe() { return get_value(); }
diff --git a/test/unit_tests/shared/command.hpp b/test/unit_tests/shared/command.hpp
index 266903f..4a91370 100644
--- a/test/unit_tests/shared/command.hpp
+++ b/test/unit_tests/shared/command.hpp
@@ -33,15 +33,6 @@ BOOST_STATIC_CONSTEXPR auto COMMAND_SHMEM_NAME = "shmem-test-cmd";
class Command {
public:
- typedef winapi::SharedObject<Command> Shared;
-
- static Shared create() { return Shared::create(COMMAND_SHMEM_NAME); }
- static Shared open() { return Shared::open(COMMAND_SHMEM_NAME); }
-
- typedef boost::interprocess::interprocess_mutex mutex;
- typedef boost::interprocess::interprocess_condition condition_variable;
- typedef boost::interprocess::scoped_lock<mutex> lock;
-
enum Action {
EXIT = 1,
GET_CONSOLE_WINDOW,
@@ -62,8 +53,18 @@ public:
fixed_size::StringList<> console_buffer;
};
+ typedef winapi::SharedObject<Command> Shared;
+
+ typedef boost::interprocess::interprocess_mutex mutex;
+ typedef boost::interprocess::interprocess_condition condition_variable;
+ typedef boost::interprocess::scoped_lock<mutex> lock;
+
typedef std::function<void(Args&)> SetArgs;
typedef std::function<void(const Result&)> ReadResult;
+ typedef std::function<void(Action, const Args&, Result&)> ProcessAction;
+
+ static Shared create() { return Shared::create(COMMAND_SHMEM_NAME); }
+ static Shared open() { return Shared::open(COMMAND_SHMEM_NAME); }
void get_result(Action action, const SetArgs& set_args, const ReadResult& read_result) {
{
@@ -104,8 +105,6 @@ public:
return get_result(action, [](const Result&) {});
}
- typedef std::function<void(Action, const Args&, Result&)> ProcessAction;
-
void process_action(const ProcessAction& callback) {
{
lock lck{m_mtx};
diff --git a/test/unit_tests/shared/console.hpp b/test/unit_tests/shared/console.hpp
index faa887c..274c232 100644
--- a/test/unit_tests/shared/console.hpp
+++ b/test/unit_tests/shared/console.hpp
@@ -26,9 +26,9 @@ class Buffer {
public:
typedef CONSOLE_SCREEN_BUFFER_INFO Info;
- Buffer() : m_handle{winapi::Handle::std_out()}, m_info(get_info(m_handle)) {}
+ Buffer() : m_handle(winapi::Handle::std_out()), m_info(get_info(m_handle)) {}
- Buffer(winapi::Handle&& handle) : m_handle{std::move(handle)}, m_info(get_info(m_handle)) {}
+ Buffer(winapi::Handle&& handle) : m_handle(std::move(handle)), m_info(get_info(m_handle)) {}
std::size_t get_columns() const { return m_info.dwSize.X; }
diff --git a/test/unit_tests/shared/fixed_size.hpp b/test/unit_tests/shared/fixed_size.hpp
index e4b11c7..ba9a128 100644
--- a/test/unit_tests/shared/fixed_size.hpp
+++ b/test/unit_tests/shared/fixed_size.hpp
@@ -38,8 +38,6 @@ public:
// Lines are null-terminated, and don't store their lenghts, so...
return data();
}
-
-private:
};
// 5 lines to store is also arbitrary, set it higher if needed.
diff --git a/test/unit_tests/shared/worker.hpp b/test/unit_tests/shared/worker.hpp
index 320a924..a1067ac 100644
--- a/test/unit_tests/shared/worker.hpp
+++ b/test/unit_tests/shared/worker.hpp
@@ -9,6 +9,8 @@
#include <winapi/process.hpp>
+#include <boost/config.hpp>
+
#include <windows.h>
#include <exception>
@@ -20,7 +22,23 @@ namespace worker {
class Worker {
public:
- Worker(winapi::Process&& process) : m_cmd{Command::create()}, m_process{std::move(process)} {}
+ Worker(winapi::Process&& process) : m_cmd(Command::create()), m_process(std::move(process)) {}
+
+ Worker(Worker&& other) BOOST_NOEXCEPT_OR_NOTHROW : m_cmd(std::move(other.m_cmd)),
+ m_process(std::move(other.m_process)) {}
+
+ Worker& operator=(Worker other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+ }
+
+ void swap(Worker& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ swap(m_cmd, other.m_cmd);
+ swap(m_process, other.m_process);
+ }
+
+ Worker(const Worker&) = delete;
~Worker() {
try {
@@ -83,4 +101,17 @@ private:
winapi::Process m_process;
};
+inline void swap(Worker& a, Worker& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
} // namespace worker
+
+namespace std {
+
+template <>
+inline void swap(worker::Worker& a, worker::Worker& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+} // namespace std