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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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