Add noexcept qualifier to swaps and moves.

This commit is contained in:
Tom Ritchford
2015-02-10 12:57:29 -05:00
parent 69b4cd22a2
commit a963a6d10d
11 changed files with 24 additions and 24 deletions

View File

@@ -194,7 +194,7 @@ void TransactionMetaSet::init (uint256 const& id, std::uint32_t ledger)
mDelivered = boost::optional <STAmount> (); mDelivered = boost::optional <STAmount> ();
} }
void TransactionMetaSet::swap (TransactionMetaSet& s) void TransactionMetaSet::swap (TransactionMetaSet& s) noexcept
{ {
assert ((mTransactionID == s.mTransactionID) && (mLedger == s.mLedger)); assert ((mTransactionID == s.mTransactionID) && (mLedger == s.mLedger));
mNodes.swap (s.mNodes); mNodes.swap (s.mNodes);

View File

@@ -56,7 +56,7 @@ public:
{ {
mNodes.clear (); mNodes.clear ();
} }
void swap (TransactionMetaSet&); void swap (TransactionMetaSet&) noexcept;
uint256 const& getTxID () uint256 const& getTxID ()
{ {

View File

@@ -241,7 +241,7 @@ ValueInternalMap::~ValueInternalMap ()
void void
ValueInternalMap::swap ( ValueInternalMap& other ) ValueInternalMap::swap ( ValueInternalMap& other ) noexcept
{ {
ValueInternalLink* tempBuckets = buckets_; ValueInternalLink* tempBuckets = buckets_;
buckets_ = other.buckets_; buckets_ = other.buckets_;

View File

@@ -208,7 +208,7 @@ Value::CZString::~CZString ()
} }
void void
Value::CZString::swap ( CZString& other ) Value::CZString::swap ( CZString& other ) noexcept
{ {
std::swap ( cstr_, other.cstr_ ); std::swap ( cstr_, other.cstr_ );
std::swap ( index_, other.index_ ); std::swap ( index_, other.index_ );
@@ -558,7 +558,7 @@ Value::operator= ( const Value& other )
return *this; return *this;
} }
Value::Value ( Value&& other ) Value::Value ( Value&& other ) noexcept
: value_ ( other.value_ ) : value_ ( other.value_ )
, type_ ( other.type_ ) , type_ ( other.type_ )
, allocated_ ( other.allocated_ ) , allocated_ ( other.allocated_ )
@@ -572,14 +572,14 @@ Value::Value ( Value&& other )
} }
Value& Value&
Value::operator= ( Value&& other ) Value::operator= ( Value&& other ) noexcept
{ {
swap ( other ); swap ( other );
return *this; return *this;
} }
void void
Value::swap ( Value& other ) Value::swap ( Value& other ) noexcept
{ {
std::swap ( value_, other.value_ ); std::swap ( value_, other.value_ );

View File

@@ -165,7 +165,7 @@ private:
const char* c_str () const; const char* c_str () const;
bool isStaticString () const; bool isStaticString () const;
private: private:
void swap ( CZString& other ); void swap ( CZString& other ) noexcept;
const char* cstr_; const char* cstr_;
int index_; int index_;
}; };
@@ -224,13 +224,13 @@ public:
Value& operator= ( const Value& other ); Value& operator= ( const Value& other );
Value ( Value&& other ); Value ( Value&& other ) noexcept;
Value& operator= ( Value&& other ); Value& operator= ( Value&& other ) noexcept;
/// Swap values. /// Swap values.
/// \note Currently, comments are intentionally not swapped, for /// \note Currently, comments are intentionally not swapped, for
/// both logic and efficiency. /// both logic and efficiency.
void swap ( Value& other ); void swap ( Value& other ) noexcept;
ValueType type () const; ValueType type () const;
@@ -678,7 +678,7 @@ public:
ValueInternalMap& operator = ( const ValueInternalMap& other ); ValueInternalMap& operator = ( const ValueInternalMap& other );
~ValueInternalMap (); ~ValueInternalMap ();
void swap ( ValueInternalMap& other ); void swap ( ValueInternalMap& other ) noexcept;
BucketIndex size () const; BucketIndex size () const;
@@ -774,7 +774,7 @@ public:
ValueInternalArray ( const ValueInternalArray& other ); ValueInternalArray ( const ValueInternalArray& other );
ValueInternalArray& operator = ( const ValueInternalArray& other ); ValueInternalArray& operator = ( const ValueInternalArray& other );
~ValueInternalArray (); ~ValueInternalArray ();
void swap ( ValueInternalArray& other ); void swap ( ValueInternalArray& other ) noexcept;
void clear (); void clear ();
void resize ( ArrayIndex newSize ); void resize ( ArrayIndex newSize );

View File

@@ -170,7 +170,7 @@ public:
{ {
value.clear (); value.clear ();
} }
void swap (STArray & a) void swap (STArray & a) noexcept
{ {
value.swap (a.value); value.swap (a.value);
} }

View File

@@ -42,7 +42,7 @@ Collection::~Collection ()
parent_->enabled_ = true; parent_->enabled_ = true;
} }
Collection& Collection::operator= (Collection&& that) Collection& Collection::operator= (Collection&& that) noexcept
{ {
parent_ = that.parent_; parent_ = that.parent_;
writer_ = that.writer_; writer_ = that.writer_;
@@ -55,7 +55,7 @@ Collection& Collection::operator= (Collection&& that)
return *this; return *this;
} }
Collection::Collection (Collection&& that) Collection::Collection (Collection&& that) noexcept
{ {
*this = std::move (that); *this = std::move (that);
} }

View File

@@ -151,8 +151,8 @@ namespace RPC {
class Collection class Collection
{ {
public: public:
Collection (Collection&& c); Collection (Collection&& c) noexcept;
Collection& operator= (Collection&& c); Collection& operator= (Collection&& c) noexcept;
Collection() = delete; Collection() = delete;
~Collection(); ~Collection();
@@ -294,7 +294,7 @@ public:
} }
#ifdef _MSC_VER #ifdef _MSC_VER
WriterObject (WriterObject&& other) WriterObject (WriterObject&& other) noexcept
: writer_ (std::move (other.writer_)), : writer_ (std::move (other.writer_)),
object_ (std::move (other.object_)) object_ (std::move (other.object_))
{ {

View File

@@ -220,12 +220,12 @@ Writer::~Writer()
impl_->finishAll (); impl_->finishAll ();
} }
Writer::Writer(Writer&& w) Writer::Writer(Writer&& w) noexcept
{ {
impl_ = std::move (w.impl_); impl_ = std::move (w.impl_);
} }
Writer& Writer::operator=(Writer&& w) Writer& Writer::operator=(Writer&& w) noexcept
{ {
impl_ = std::move (w.impl_); impl_ = std::move (w.impl_);
return *this; return *this;

View File

@@ -129,8 +129,8 @@ public:
enum CollectionType {array, object}; enum CollectionType {array, object};
explicit Writer (Output const& output); explicit Writer (Output const& output);
Writer(Writer&&); Writer(Writer&&) noexcept;
Writer& operator=(Writer&&); Writer& operator=(Writer&&) noexcept;
~Writer(); ~Writer();

View File

@@ -105,7 +105,7 @@ public:
return mSocket->lowest_layer (); return mSocket->lowest_layer ();
} }
void swap (AutoSocket& s) void swap (AutoSocket& s) noexcept
{ {
mBuffer.swap (s.mBuffer); mBuffer.swap (s.mBuffer);
mSocket.swap (s.mSocket); mSocket.swap (s.mSocket);