move construction/assignment should be noexcept where possible

This commit is contained in:
Danny Robson 2018-07-24 15:48:50 +10:00
parent 503ed940ac
commit cf800a35da
10 changed files with 17 additions and 17 deletions

View File

@ -32,7 +32,7 @@ library_posix::library_posix (const std::experimental::filesystem::path &path):
//-----------------------------------------------------------------------------
library_posix::library_posix (library_posix &&rhs):
library_posix::library_posix (library_posix &&rhs) noexcept:
m_handle (nullptr)
{
std::swap (m_handle, rhs.m_handle);

View File

@ -26,7 +26,7 @@ namespace util {
class library_posix {
public:
explicit library_posix (const std::experimental::filesystem::path&);
library_posix (library_posix&&);
library_posix (library_posix&&) noexcept;
~library_posix ();
library_posix (const library_posix&) = delete;

View File

@ -38,7 +38,7 @@ fd::fd (const std::experimental::filesystem::path &path, int flags, mode_t mode)
///////////////////////////////////////////////////////////////////////////////
fd::fd (fd &&rhs):
fd::fd (fd &&rhs) noexcept:
m_fd (-1)
{
std::swap (m_fd, rhs.m_fd);
@ -47,7 +47,7 @@ fd::fd (fd &&rhs):
//-----------------------------------------------------------------------------
fd&
fd::operator= (fd &&rhs)
fd::operator= (fd &&rhs) noexcept
{
close ();
std::swap (m_fd, rhs.m_fd);

View File

@ -34,8 +34,8 @@ namespace util::posix {
fd (const std::experimental::filesystem::path &path, int flags);
fd (const std::experimental::filesystem::path &path, int flags, mode_t);
fd (fd &&);
fd& operator= (fd &&);
fd (fd &&) noexcept;
fd& operator= (fd &&) noexcept;
fd& operator= (int);
// The int constructor steals the fd. So don't pass in something that

View File

@ -42,7 +42,7 @@ map::map (size_t size, int prot, int flags, const fd &src, off_t offset):
//-----------------------------------------------------------------------------
map::map (map &&rhs):
map::map (map &&rhs) noexcept:
m_addr (MAP_FAILED),
m_size (rhs.m_size)
{
@ -63,7 +63,7 @@ map::~map ()
//-----------------------------------------------------------------------------
map&
map::operator= (map &&rhs)
map::operator= (map &&rhs) noexcept
{
std::swap (m_addr, rhs.m_addr);
std::swap (m_size, rhs.m_size);

View File

@ -27,14 +27,14 @@ namespace util::posix {
class map {
public:
map (const map&) = delete;
map (map&&);
map (map&&) noexcept;
map (size_t size, int prot, int flags);
map (size_t size, int prot, int flags, const fd&, off_t offset = 0);
~map ();
map& operator= (const map&) = delete;
map& operator= (map&&);
map& operator= (map&&) noexcept;
uint8_t* begin (void);
uint8_t* end (void);

View File

@ -120,14 +120,14 @@ socket::~socket ()
//-----------------------------------------------------------------------------
socket::socket (socket &&rhs):
socket::socket (socket &&rhs) noexcept:
fd (std::move (rhs))
{ ; }
//-----------------------------------------------------------------------------
class socket&
socket::operator= (socket &&rhs)
socket::operator= (socket &&rhs) noexcept
{
fd::operator= (std::move (rhs));
return *this;

View File

@ -38,8 +38,8 @@ namespace util::posix {
socket (const socket&) = delete;
socket& operator= (const socket&) = delete;
socket (socket &&rhs);
socket& operator= (socket &&);
socket (socket &&rhs) noexcept;
socket& operator= (socket &&) noexcept;
// the destructor is provided so that we can operate more cleanly on
// win32 where we must call closesocket instead of the normal close.

View File

@ -28,7 +28,7 @@ spinlock::spinlock ():
//-----------------------------------------------------------------------------
spinlock::spinlock (spinlock &&rhs):
spinlock::spinlock (spinlock &&rhs) noexcept:
held (rhs.held.load ())
{ ; }

View File

@ -30,8 +30,8 @@ namespace util::thread {
class spinlock {
public:
spinlock ();
spinlock (spinlock &&);
spinlock& operator= (spinlock &&);
spinlock (spinlock &&) noexcept;
spinlock& operator= (spinlock &&) noexcept;
spinlock (const spinlock&) = delete;
spinlock& operator= (const spinlock&) = delete;