Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use noexcept instead of dynamic exception specifications #718

Merged
merged 2 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/arch/XArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "common/common.h"
#include "common/stdstring.h"
#include "common/stdexcept.h"
#include <stdexcept>

//! Generic thread exception
/*!
Expand Down Expand Up @@ -56,7 +56,7 @@ string for that error code.
class XArchEval {
public:
XArchEval() { }
virtual ~XArchEval() _NOEXCEPT { }
virtual ~XArchEval() noexcept { }

virtual std::string eval() const = 0;
};
Expand All @@ -66,7 +66,7 @@ class XArch : public std::runtime_error {
public:
XArch(XArchEval* adopted) : std::runtime_error(adopted->eval()) { delete adopted; }
XArch(const std::string& msg) : std::runtime_error(msg) { }
virtual ~XArch() _NOEXCEPT { }
virtual ~XArch() noexcept { }
};

// Macro to declare XArch derived types
Expand Down
2 changes: 1 addition & 1 deletion src/lib/arch/unix/XArchUnix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class XArchEvalUnix : public XArchEval {
public:
XArchEvalUnix(int error) : m_error(error) { }
virtual ~XArchEvalUnix() _NOEXCEPT { }
virtual ~XArchEvalUnix() noexcept { }

virtual std::string eval() const;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/arch/win32/XArchWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//

std::string
XArchEvalWindows::eval() const throw()
XArchEvalWindows::eval() const noexcept
{
char* cmsg;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
Expand All @@ -50,7 +50,7 @@ XArchEvalWindows::eval() const throw()
//

std::string
XArchEvalWinsock::eval() const throw()
XArchEvalWinsock::eval() const noexcept
{
// built-in windows function for looking up error message strings
// may not look up network error messages correctly. we'll have
Expand Down
1 change: 0 additions & 1 deletion src/lib/barrier/PlatformScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "barrier/IPlatformScreen.h"
#include "barrier/DragInformation.h"
#include "common/stdexcept.h"

//! Base screen implementation
/*!
Expand Down
2 changes: 1 addition & 1 deletion src/lib/barrier/ProtocolUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ ProtocolUtil::read(barrier::IStream* stream, void* vbuffer, UInt32 count)
//

String
XIOReadMismatch::getWhat() const throw()
XIOReadMismatch::getWhat() const noexcept
{
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
}
2 changes: 1 addition & 1 deletion src/lib/barrier/ProtocolUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ match the format.
class XIOReadMismatch : public XIO {
public:
// XBase overrides
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
};
2 changes: 1 addition & 1 deletion src/lib/barrier/StreamChunker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "base/String.h"
#include "common/stdexcept.h"

#include <fstream>
#include <stdexcept>

using namespace std;

Expand Down
30 changes: 10 additions & 20 deletions src/lib/barrier/XBarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
// XBadClient
//

String
XBadClient::getWhat() const throw()
String XBadClient::getWhat() const noexcept
{
return "XBadClient";
}
Expand All @@ -41,20 +40,17 @@ XIncompatibleClient::XIncompatibleClient(int major, int minor) :
// do nothing
}

int
XIncompatibleClient::getMajor() const throw()
int XIncompatibleClient::getMajor() const noexcept
{
return m_major;
}

int
XIncompatibleClient::getMinor() const throw()
int XIncompatibleClient::getMinor() const noexcept
{
return m_minor;
}

String
XIncompatibleClient::getWhat() const throw()
String XIncompatibleClient::getWhat() const noexcept
{
return format("XIncompatibleClient", "incompatible client %{1}.%{2}",
barrier::string::sprintf("%d", m_major).c_str(),
Expand All @@ -72,14 +68,12 @@ XDuplicateClient::XDuplicateClient(const String& name) :
// do nothing
}

const String&
XDuplicateClient::getName() const throw()
const String& XDuplicateClient::getName() const noexcept
{
return m_name;
}

String
XDuplicateClient::getWhat() const throw()
String XDuplicateClient::getWhat() const noexcept
{
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
}
Expand All @@ -95,14 +89,12 @@ XUnknownClient::XUnknownClient(const String& name) :
// do nothing
}

const String&
XUnknownClient::getName() const throw()
const String& XUnknownClient::getName() const noexcept
{
return m_name;
}

String
XUnknownClient::getWhat() const throw()
String XUnknownClient::getWhat() const noexcept
{
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
}
Expand All @@ -118,14 +110,12 @@ XExitApp::XExitApp(int code) :
// do nothing
}

int
XExitApp::getCode() const throw()
int XExitApp::getCode() const noexcept
{
return m_code;
}

String
XExitApp::getWhat() const throw()
String XExitApp::getWhat() const noexcept
{
return format(
"XExitApp", "exiting with code %{1}",
Expand Down
24 changes: 12 additions & 12 deletions src/lib/barrier/XBarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class XIncompatibleClient : public XBarrier {
//@{

//! Get client's major version number
int getMajor() const throw();
int getMajor() const noexcept;
//! Get client's minor version number
int getMinor() const throw();
int getMinor() const noexcept;

//@}

protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;

private:
int m_major;
Expand All @@ -69,18 +69,18 @@ a client that is already connected.
class XDuplicateClient : public XBarrier {
public:
XDuplicateClient(const std::string& name);
virtual ~XDuplicateClient() _NOEXCEPT { }
virtual ~XDuplicateClient() noexcept { }

//! @name accessors
//@{

//! Get client's name
virtual const std::string& getName() const throw();
virtual const std::string& getName() const noexcept;

//@}

protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;

private:
std::string m_name;
Expand All @@ -94,18 +94,18 @@ unknown to the server.
class XUnknownClient : public XBarrier {
public:
XUnknownClient(const std::string& name);
virtual ~XUnknownClient() _NOEXCEPT { }
virtual ~XUnknownClient() noexcept { }

//! @name accessors
//@{

//! Get the client's name
virtual const std::string& getName() const throw();
virtual const std::string& getName() const noexcept;

//@}

protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;

private:
std::string m_name;
Expand All @@ -120,13 +120,13 @@ exit(int).
class XExitApp : public XBarrier {
public:
XExitApp(int code);
virtual ~XExitApp() _NOEXCEPT { }
virtual ~XExitApp() noexcept { }

//! Get the exit code
int getCode() const throw();
int getCode() const noexcept;

protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;

private:
int m_code;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/barrier/XScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// XScreenOpenFailure
//

std::string XScreenOpenFailure::getWhat() const throw()
std::string XScreenOpenFailure::getWhat() const noexcept
{
return format("XScreenOpenFailure", "unable to open screen");
}
Expand All @@ -32,7 +32,7 @@ std::string XScreenOpenFailure::getWhat() const throw()
// XScreenXInputFailure
//

std::string XScreenXInputFailure::getWhat() const throw()
std::string XScreenXInputFailure::getWhat() const noexcept
{
return "";
}
Expand All @@ -48,7 +48,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) :
// do nothing
}

XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT
XScreenUnavailable::~XScreenUnavailable() noexcept
{
// do nothing
}
Expand All @@ -59,7 +59,7 @@ XScreenUnavailable::getRetryTime() const
return m_timeUntilRetry;
}

std::string XScreenUnavailable::getWhat() const throw()
std::string XScreenUnavailable::getWhat() const noexcept
{
return format("XScreenUnavailable", "unable to open screen");
}
4 changes: 2 additions & 2 deletions src/lib/barrier/XScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class XScreenUnavailable : public XScreenOpenFailure {
trying to open the screen again.
*/
XScreenUnavailable(double timeUntilRetry);
virtual ~XScreenUnavailable() _NOEXCEPT;
virtual ~XScreenUnavailable() noexcept;

//! @name manipulators
//@{
Expand All @@ -61,7 +61,7 @@ class XScreenUnavailable : public XScreenOpenFailure {
//@}

protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;

private:
double m_timeUntilRetry;
Expand Down
7 changes: 3 additions & 4 deletions src/lib/base/XBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ XBase::XBase(const std::string& msg) :
// do nothing
}

XBase::~XBase() _NOEXCEPT
XBase::~XBase() noexcept
{
// do nothing
}

const char*
XBase::what() const _NOEXCEPT
XBase::what() const noexcept
{
const char* what = std::runtime_error::what();
if (strlen(what) == 0) {
Expand All @@ -54,8 +54,7 @@ XBase::what() const _NOEXCEPT
return what;
}

std::string
XBase::format(const char* /*id*/, const char* fmt, ...) const throw()
std::string XBase::format(const char* /*id*/, const char* fmt, ...) const noexcept
{
// FIXME -- lookup message string using id as an index. set
// fmt to that string if it exists.
Expand Down
Loading