Mark move constructors as noexcept

Or just default them for non-MSVC when possible.
This commit is contained in:
Thomas Goyne 2014-04-17 09:02:05 -07:00
parent 09d0d039e0
commit 56699e4800
7 changed files with 30 additions and 17 deletions

View file

@ -33,7 +33,7 @@ namespace agi {
/// @brief An iterator over lines in a stream
template<class OutputType = std::string>
class line_iterator final : public std::iterator<std::input_iterator_tag, OutputType> {
std::istream *stream; ///< Stream to iterator over
std::istream *stream = nullptr; ///< Stream to iterator over
OutputType value; ///< Value to return when this is dereference
std::shared_ptr<agi::charset::IconvWrapper> conv;
int cr; ///< CR character in the source encoding
@ -77,7 +77,7 @@ public:
}
/// @brief Invalid iterator constructor; use for end iterator
line_iterator() : stream(nullptr) { }
line_iterator() = default;
/// @brief Copy constructor
/// @param that line_iterator to copy from

View file

@ -88,10 +88,10 @@ class OptionValue {
protected:
void NotifyChanged() { ValueChanged(*this); }
OptionValue(std::string name) : name(std::move(name)) { }
OptionValue(std::string name) BOOST_NOEXCEPT : name(std::move(name)) { }
public:
virtual ~OptionValue() {}
virtual ~OptionValue() = default;
std::string GetName() const { return name; }
virtual OptionType GetType() const = 0;

View file

@ -49,10 +49,10 @@ namespace detail {
class Connection {
std::unique_ptr<detail::ConnectionToken> token;
public:
Connection() { }
Connection(Connection&& that) : token(std::move(that.token)) { }
Connection(detail::ConnectionToken *token) : token(token) { token->claimed = true; }
Connection& operator=(Connection&& that) { token = std::move(that.token); return *this; }
Connection() = default;
Connection(Connection&& that) BOOST_NOEXCEPT : token(std::move(that.token)) { }
Connection(detail::ConnectionToken *token) BOOST_NOEXCEPT : token(token) { token->claimed = true; }
Connection& operator=(Connection&& that) BOOST_NOEXCEPT { token = std::move(that.token); return *this; }
/// @brief End this connection
///

View file

@ -55,6 +55,7 @@ AssOverrideParameter::AssOverrideParameter(VariableDataType type, AssParameterCl
{
}
#ifdef _MSC_VER
AssOverrideParameter::AssOverrideParameter(AssOverrideParameter&& o)
: value(std::move(o.value))
, block(std::move(o.block))
@ -71,6 +72,7 @@ AssOverrideParameter& AssOverrideParameter::operator=(AssOverrideParameter&& rhs
classification = rhs.classification;
return *this;
}
#endif
AssOverrideParameter::~AssOverrideParameter() {
}
@ -460,10 +462,11 @@ void AssDialogueBlockOverride::ProcessParameters(ProcessParametersCallback callb
}
}
AssOverrideTag::AssOverrideTag() : valid(false) { }
AssOverrideTag::AssOverrideTag(std::string const& text) {
SetText(text);
}
#ifdef _MSC_VER
AssOverrideTag::AssOverrideTag(AssOverrideTag&& rhs)
: valid(rhs.valid)
, Name(std::move(rhs.Name))
@ -477,6 +480,7 @@ AssOverrideTag& AssOverrideTag::operator=(AssOverrideTag&& rhs) {
Params = std::move(rhs.Params);
return *this;
}
#endif
void AssOverrideTag::Clear() {
Params.clear();

View file

@ -32,7 +32,6 @@
/// @ingroup subs_storage
///
#include <boost/noncopyable.hpp>
#include <memory>
#include <vector>
@ -62,15 +61,20 @@ enum class VariableDataType {
};
/// A single parameter to an override tag
class AssOverrideParameter final : boost::noncopyable {
class AssOverrideParameter {
std::string value;
mutable std::unique_ptr<AssDialogueBlockOverride> block;
VariableDataType type;
public:
AssOverrideParameter(VariableDataType type, AssParameterClass classification);
#ifdef _MSC_VER
AssOverrideParameter(AssOverrideParameter&&);
AssOverrideParameter& operator=(AssOverrideParameter&&);
#else
AssOverrideParameter(AssOverrideParameter&&) = default;
AssOverrideParameter& operator=(AssOverrideParameter&&) = default;
#endif
~AssOverrideParameter();
/// Type of parameter
@ -87,14 +91,19 @@ public:
}
};
class AssOverrideTag final : boost::noncopyable {
bool valid;
class AssOverrideTag {
bool valid = false;
public:
AssOverrideTag();
AssOverrideTag(AssOverrideTag&&);
AssOverrideTag() = default;
AssOverrideTag(std::string const& text);
#ifdef _MSC_VER
AssOverrideTag(AssOverrideTag&&);
AssOverrideTag& operator=(AssOverrideTag&&);
#else
AssOverrideTag(AssOverrideTag&&) = default;
AssOverrideTag& operator=(AssOverrideTag&&) = default;
#endif
std::string Name;
std::vector<AssOverrideParameter> Params;

View file

@ -99,7 +99,7 @@ class DataBlockCache {
BlockArray blocks;
#ifdef _MSC_VER
MacroBlock() { }
MacroBlock() = default;
MacroBlock(MacroBlock&& rgt) : position(rgt.position), blocks(std::move(rgt.blocks)) { }
MacroBlock& operator=(MacroBlock&& rgt) {
position = rgt.position;

View file

@ -187,7 +187,7 @@ public:
TryToInsert(glyph);
}
OpenGLTextTexture(OpenGLTextTexture&& rhs)
OpenGLTextTexture(OpenGLTextTexture&& rhs) BOOST_NOEXCEPT
: x(rhs.x)
, y(rhs.y)
, nextY(rhs.nextY)