Used constexpr and noexcept keywords directly
We can do this now since were bumping min compiler support.
(cherry-picked from commit 8120843b2e
)
This commit is contained in:
parent
9b7e1ed383
commit
24cc0b01d4
23 changed files with 43 additions and 61 deletions
|
@ -44,7 +44,7 @@ struct editor_map_load_exception : public editor_exception
|
|||
: editor_exception(msg), filename(fn)
|
||||
{
|
||||
}
|
||||
~editor_map_load_exception() NOEXCEPT {}
|
||||
~editor_map_load_exception() noexcept {}
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct editor_map_save_exception : public editor_exception
|
|||
: editor_exception(msg)
|
||||
{
|
||||
}
|
||||
~editor_map_save_exception() NOEXCEPT {}
|
||||
~editor_map_save_exception() noexcept {}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ struct error : std::exception
|
|||
|
||||
error() : message() {}
|
||||
error(const std::string &msg) : message(msg) {}
|
||||
~error() NOEXCEPT {}
|
||||
~error() noexcept {}
|
||||
|
||||
const char *what() const NOEXCEPT
|
||||
const char *what() const noexcept
|
||||
{
|
||||
return message.c_str();
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ namespace {
|
|||
public:
|
||||
|
||||
//Not used by boost filesystem
|
||||
int do_encoding() const NOEXCEPT { return 0; }
|
||||
int do_encoding() const noexcept { return 0; }
|
||||
//Not used by boost filesystem
|
||||
bool do_always_noconv() const NOEXCEPT { return false; }
|
||||
bool do_always_noconv() const noexcept { return false; }
|
||||
int do_length( std::mbstate_t& /*state*/,
|
||||
const char* /*from*/,
|
||||
const char* /*from_end*/,
|
||||
|
|
|
@ -100,7 +100,7 @@ struct formula_error : public game::error
|
|||
formula_error(const std::string& type, const std::string& formula,
|
||||
const std::string& file, int line);
|
||||
|
||||
~formula_error() NOEXCEPT {}
|
||||
~formula_error() noexcept {}
|
||||
|
||||
std::string type;
|
||||
std::string formula;
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
, std::exception()
|
||||
{
|
||||
}
|
||||
const char * what() const NOEXCEPT { return "return_to_play_side_exception"; }
|
||||
const char * what() const noexcept { return "return_to_play_side_exception"; }
|
||||
private:
|
||||
|
||||
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(return_to_play_side_exception)
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
, std::exception()
|
||||
{
|
||||
}
|
||||
const char * what() const NOEXCEPT { return "quit_game_exception"; }
|
||||
const char * what() const noexcept { return "quit_game_exception"; }
|
||||
private:
|
||||
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(quit_game_exception)
|
||||
};
|
||||
|
|
|
@ -50,12 +50,8 @@
|
|||
#if _MSC_VER >= 1900
|
||||
#define HAVE_REF_QUALIFIERS 1
|
||||
#define HAVE_INHERITING_CTORS 1
|
||||
#define CONSTEXPR constexpr
|
||||
#define NOEXCEPT noexcept
|
||||
#define NORETURN [[noreturn]]
|
||||
#else
|
||||
#define CONSTEXPR
|
||||
#define NOEXCEPT throw()
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#endif
|
||||
// MSVC supports these starting in 2017?
|
||||
|
@ -92,25 +88,12 @@
|
|||
// Use GCC-style attribute because the __has_cpp_attribute feature-checking macro doesn't exist in clang 3.5
|
||||
#define DEPRECATED(reason) __attribute__((deprecated(reason)))
|
||||
|
||||
#if __has_feature(cxx_constexpr)
|
||||
#define CONSTEXPR constexpr
|
||||
#else
|
||||
#define CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_noexcept)
|
||||
#define NOEXCEPT noexcept
|
||||
#else
|
||||
#define NOEXCEPT throw()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// GCC 5 required for this
|
||||
#define HAVE_PUT_TIME (__GNUC__ >= 5)
|
||||
// GCC supports these from 4.8 up
|
||||
#define CONSTEXPR constexpr
|
||||
#define NOEXCEPT noexcept
|
||||
#define NORETURN [[noreturn]]
|
||||
#define HAVE_REF_QUALIFIERS 1
|
||||
#define HAVE_INHERITING_CTORS 1
|
||||
|
|
|
@ -344,14 +344,14 @@ private:
|
|||
* utilize a move constructor as long as a non-throwing one is provided.
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013
|
||||
child(child&& c) NOEXCEPT
|
||||
child(child&& c) noexcept
|
||||
: flags_(c.flags_)
|
||||
, border_size_(c.border_size_)
|
||||
, widget_(std::move(c.widget_))
|
||||
{
|
||||
}
|
||||
#else
|
||||
child(child&&) NOEXCEPT = default;
|
||||
child(child&&) noexcept = default;
|
||||
#endif
|
||||
|
||||
/** Returns the best size for the cell. */
|
||||
|
|
|
@ -120,10 +120,10 @@ static inline std::string get_hp_tooltip(const utils::string_map& res, const std
|
|||
const int res_def = 100 - get(resist.first, false);
|
||||
|
||||
if(res_att == res_def) {
|
||||
line << "<span color='" << unit_helper::resistance_color(res_def) << "'>" << utils::signed_percent(res_def) << "</span>";
|
||||
line << "<span color='" << unit_helper::resistance_color(res_def) << "'>\t" << utils::signed_percent(res_def) << "</span>";
|
||||
} else {
|
||||
line << "<span color='" << unit_helper::resistance_color(res_att) << "'>" << utils::signed_percent(res_att) << "</span>" << "/"
|
||||
<< "<span color='" << unit_helper::resistance_color(res_def) << "'>" << utils::signed_percent(res_def) << "</span>";
|
||||
line << "<span color='" << unit_helper::resistance_color(res_att) << "'>\t" << utils::signed_percent(res_att) << "</span>" << "/"
|
||||
<< "<span color='" << unit_helper::resistance_color(res_def) << "'>" << utils::signed_percent(res_def) << "</span>";
|
||||
att_def_diff = true;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ static inline std::string get_mp_tooltip(int total_movement, std::function<int (
|
|||
color = "white";
|
||||
}
|
||||
|
||||
tooltip << "<span color='" << color << "'>";
|
||||
tooltip << "\t<span color='" << color << "'>";
|
||||
|
||||
// A 5 MP margin; if the movement costs go above the unit's max moves + 5, we replace it with dashes.
|
||||
if(cannot_move && (moves > total_movement + 5)) {
|
||||
|
@ -250,7 +250,7 @@ void unit_preview_pane::set_displayed_type(const unit_type& type)
|
|||
+ ")";
|
||||
}
|
||||
|
||||
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
|
||||
mods += "~XBRZ(2)~SCALE_INTO_SHARP(144,144)" + image_mods_;
|
||||
|
||||
icon_type_->set_label((type.icon().empty() ? type.image() : type.icon()) + mods);
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ void unit_preview_pane::set_displayed_unit(const unit& u)
|
|||
mods += "~BLIT(" + overlay + ")";
|
||||
}
|
||||
|
||||
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
|
||||
mods += "~XBRZ(2)~SCALE_INTO_SHARP(144,144)" + image_mods_;
|
||||
|
||||
icon_type_->set_label(u.absolute_image() + mods);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
*/
|
||||
imod_exception(const std::string& message);
|
||||
|
||||
~imod_exception() NOEXCEPT {}
|
||||
~imod_exception() noexcept {}
|
||||
|
||||
/** The error message regarding the failed operation. */
|
||||
const std::string message;
|
||||
|
|
|
@ -116,7 +116,7 @@ inline To lexical_cast_default(From value, To fallback = To())
|
|||
/** Thrown when a lexical_cast fails. */
|
||||
struct bad_lexical_cast : std::exception
|
||||
{
|
||||
const char* what() const NOEXCEPT
|
||||
const char* what() const noexcept
|
||||
{
|
||||
return "bad_lexical_cast";
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~libc_error() NOEXCEPT
|
||||
virtual ~libc_error() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
}
|
||||
|
||||
/** Returns an explanatory string describing the exception. */
|
||||
const char* what() const NOEXCEPT
|
||||
const char* what() const noexcept
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ std::string get_timespan(const time_t& t) {
|
|||
return sout.str();
|
||||
}
|
||||
|
||||
static void print_precise_timestamp(std::ostream & out) NOEXCEPT
|
||||
static void print_precise_timestamp(std::ostream & out) noexcept
|
||||
{
|
||||
try {
|
||||
facet.put(
|
||||
|
@ -238,7 +238,7 @@ std::ostream &logger::operator()(const log_domain& domain, bool show_names, bool
|
|||
}
|
||||
}
|
||||
|
||||
void scope_logger::do_log_entry(const log_domain& domain, const std::string& str) NOEXCEPT
|
||||
void scope_logger::do_log_entry(const log_domain& domain, const std::string& str) noexcept
|
||||
{
|
||||
output_ = &debug()(domain, false, true);
|
||||
str_ = str;
|
||||
|
@ -249,7 +249,7 @@ void scope_logger::do_log_entry(const log_domain& domain, const std::string& str
|
|||
++indent;
|
||||
}
|
||||
|
||||
void scope_logger::do_log_exit() NOEXCEPT
|
||||
void scope_logger::do_log_exit() noexcept
|
||||
{
|
||||
long ticks = 0;
|
||||
try {
|
||||
|
|
|
@ -166,8 +166,8 @@ public:
|
|||
}
|
||||
void do_indent() const;
|
||||
private:
|
||||
void do_log_entry(const log_domain& domain, const std::string& str) NOEXCEPT;
|
||||
void do_log_exit() NOEXCEPT;
|
||||
void do_log_entry(const log_domain& domain, const std::string& str) noexcept;
|
||||
void do_log_exit() noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
lua_jailbreak_exception *lua_jailbreak_exception::jailbreak_exception = nullptr;
|
||||
|
||||
void lua_jailbreak_exception::store() const NOEXCEPT
|
||||
void lua_jailbreak_exception::store() const noexcept
|
||||
{
|
||||
/*
|
||||
* It should not be possible to call this function with an exception still
|
||||
|
@ -54,7 +54,7 @@ void lua_jailbreak_exception::rethrow()
|
|||
assert(false);
|
||||
}
|
||||
|
||||
void lua_jailbreak_exception::clear() NOEXCEPT
|
||||
void lua_jailbreak_exception::clear() noexcept
|
||||
{
|
||||
delete jailbreak_exception;
|
||||
jailbreak_exception = nullptr;
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
class lua_jailbreak_exception
|
||||
{
|
||||
public:
|
||||
virtual ~lua_jailbreak_exception() NOEXCEPT {}
|
||||
virtual ~lua_jailbreak_exception() noexcept {}
|
||||
|
||||
/** Stores a copy the current exception to be rethrown. */
|
||||
void store() const NOEXCEPT;
|
||||
void store() const noexcept;
|
||||
|
||||
/**
|
||||
* Rethrows the stored exception.
|
||||
|
@ -45,7 +45,7 @@ protected:
|
|||
private:
|
||||
|
||||
/** Clears the current exception. */
|
||||
static void clear() NOEXCEPT;
|
||||
static void clear() noexcept;
|
||||
|
||||
/**
|
||||
* Creates a copy of the current exception.
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
* Contains the SDL_Rect helper code.
|
||||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include <SDL_rect.h>
|
||||
|
@ -29,7 +28,7 @@ struct point;
|
|||
namespace sdl
|
||||
{
|
||||
|
||||
CONSTEXPR const SDL_Rect empty_rect { 0, 0, 0, 0 };
|
||||
constexpr const SDL_Rect empty_rect { 0, 0, 0, 0 };
|
||||
|
||||
/**
|
||||
* Creates an SDL_Rect with the given dimensions.
|
||||
|
|
|
@ -351,7 +351,7 @@ public:
|
|||
private:
|
||||
template <typename r_iter>
|
||||
size_type reverse_distance(r_iter first, r_iter last) const BOOST_NOEXCEPT {
|
||||
// Portability note here: std::distance is not NOEXCEPT, but calling it with a string_view::reverse_iterator will not throw.
|
||||
// Portability note here: std::distance is not noexcept, but calling it with a string_view::reverse_iterator will not throw.
|
||||
return len_ - 1 - std::distance(first, last);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ using std::clamp;
|
|||
#else
|
||||
// NOTE: remove once we have C++17 support and can use std::clamp
|
||||
template<typename T>
|
||||
CONSTEXPR const T& clamp(const T& value, const T& min, const T& max)
|
||||
constexpr const T& clamp(const T& value, const T& min, const T& max)
|
||||
{
|
||||
return std::max<T>(std::min<T>(value, max), min);
|
||||
}
|
||||
|
|
|
@ -99,19 +99,19 @@ public:
|
|||
, bad_val(str)
|
||||
{}
|
||||
|
||||
virtual ~bad_enum_cast() NOEXCEPT {}
|
||||
virtual ~bad_enum_cast() noexcept {}
|
||||
|
||||
const char * what() const NOEXCEPT
|
||||
const char * what() const noexcept
|
||||
{
|
||||
return message.c_str();
|
||||
}
|
||||
|
||||
const char * type() const NOEXCEPT
|
||||
const char * type() const noexcept
|
||||
{
|
||||
return name.c_str();
|
||||
}
|
||||
|
||||
const char * value() const NOEXCEPT
|
||||
const char * value() const noexcept
|
||||
{
|
||||
return bad_val.c_str();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class name_generator_invalid_exception : public std::exception {
|
||||
public:
|
||||
name_generator_invalid_exception(const char* errMessage):errMessage_(errMessage) {}
|
||||
const char* what() const NOEXCEPT { return errMessage_; }
|
||||
const char* what() const noexcept { return errMessage_; }
|
||||
|
||||
private:
|
||||
const char* errMessage_;
|
||||
|
|
|
@ -63,7 +63,7 @@ typename V::result_t apply_visitor(typename V::param_t state, T&&... args)
|
|||
using namespace variable_info_implementation;
|
||||
|
||||
template<typename V>
|
||||
variable_info<V>::variable_info(const std::string& varname, maybe_const_t<config, V>& vars) NOEXCEPT
|
||||
variable_info<V>::variable_info(const std::string& varname, maybe_const_t<config, V>& vars) noexcept
|
||||
: name_(varname)
|
||||
, state_(vars)
|
||||
, valid_(true)
|
||||
|
|
|
@ -27,7 +27,7 @@ class invalid_variablename_exception : public std::exception
|
|||
public:
|
||||
invalid_variablename_exception() : std::exception() {}
|
||||
|
||||
const char* what() const NOEXCEPT
|
||||
const char* what() const noexcept
|
||||
{
|
||||
return "invalid_variablename_exception";
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ template<typename V>
|
|||
class variable_info
|
||||
{
|
||||
public:
|
||||
variable_info(const std::string& varname, maybe_const_t<config, V>& vars) NOEXCEPT;
|
||||
variable_info(const std::string& varname, maybe_const_t<config, V>& vars) noexcept;
|
||||
|
||||
std::string get_error_message() const;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ struct wml_exception
|
|||
{
|
||||
}
|
||||
|
||||
~wml_exception() NOEXCEPT {}
|
||||
~wml_exception() noexcept {}
|
||||
|
||||
/**
|
||||
* The message for the user explaining what went wrong. This message can
|
||||
|
|
Loading…
Add table
Reference in a new issue