Skip to content
Snippets Groups Projects
Commit 14b0d33e authored by Jan Trávníček's avatar Jan Trávníček
Browse files

using std::swap before swap calls

parent c739a234
No related branches found
No related tags found
No related merge requests found
...@@ -518,6 +518,8 @@ public: ...@@ -518,6 +518,8 @@ public:
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   
friend void swap ( forward_tree & first, forward_tree & second ) { friend void swap ( forward_tree & first, forward_tree & second ) {
using std::swap;
swap ( std::move ( first.m_data ), std::move ( second.m_data ) ); swap ( std::move ( first.m_data ), std::move ( second.m_data ) );
swap ( std::move ( first.m_children ), std::move ( second.m_children ) ); swap ( std::move ( first.m_children ), std::move ( second.m_children ) );
} }
......
...@@ -553,6 +553,8 @@ public: ...@@ -553,6 +553,8 @@ public:
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   
friend void swap ( tree & first, tree & second ) { friend void swap ( tree & first, tree & second ) {
using std::swap;
swap ( std::move ( first.m_data ), std::move ( second.m_data ) ); swap ( std::move ( first.m_data ), std::move ( second.m_data ) );
swap ( std::move ( first.m_children ), std::move ( second.m_children ) ); swap ( std::move ( first.m_children ), std::move ( second.m_children ) );
swap ( std::move ( first.m_parent ), std::move ( second.m_parent ) ); swap ( std::move ( first.m_parent ), std::move ( second.m_parent ) );
......
...@@ -113,7 +113,9 @@ public: ...@@ -113,7 +113,9 @@ public:
} }
   
AnyaryNode & operator =( AnyaryNode && other ) noexcept { AnyaryNode & operator =( AnyaryNode && other ) noexcept {
std::swap ( this->children_union.children, other.children_union.children ); using std::swap;
swap ( this->children_union.children, other.children_union.children );
   
setParent ( std::make_index_sequence < arity > ( ) ); setParent ( std::make_index_sequence < arity > ( ) );
   
...@@ -302,7 +304,9 @@ public: ...@@ -302,7 +304,9 @@ public:
} }
   
FixedaryNode & operator =( FixedaryNode && other ) noexcept { FixedaryNode & operator =( FixedaryNode && other ) noexcept {
std::swap ( this->children_union.children, other.children_union.children ); using std::swap;
swap ( this->children_union.children, other.children_union.children );
   
for ( Data & child : children_union.children ) for ( Data & child : children_union.children )
child->parent = static_cast < Cast * > ( this ); child->parent = static_cast < Cast * > ( this );
...@@ -378,7 +382,9 @@ public: ...@@ -378,7 +382,9 @@ public:
} }
   
VararyNode & operator =( VararyNode && other ) noexcept { VararyNode & operator =( VararyNode && other ) noexcept {
std::swap ( this->children_union.children, other.children_union.children ); using std::swap;
swap ( this->children_union.children, other.children_union.children );
   
for ( Data & child : children_union.children ) for ( Data & child : children_union.children )
child->parent = static_cast < Cast * > ( this ); child->parent = static_cast < Cast * > ( this );
......
...@@ -65,7 +65,9 @@ struct rvalue_ref { ...@@ -65,7 +65,9 @@ struct rvalue_ref {
rvalue_ref & operator = ( const rvalue_ref & ) = delete; rvalue_ref & operator = ( const rvalue_ref & ) = delete;
   
rvalue_ref & operator = ( rvalue_ref && other ) { rvalue_ref & operator = ( rvalue_ref && other ) {
std::swap(holder, other.holder); using std::swap;
swap(holder, other.holder);
} }
   
~rvalue_ref ( ) { ~rvalue_ref ( ) {
......
...@@ -240,8 +240,10 @@ public: ...@@ -240,8 +240,10 @@ public:
   
// move assignment operator // move assignment operator
variant<Ts...>& operator= (variant<Ts...> && old) noexcept { variant<Ts...>& operator= (variant<Ts...> && old) noexcept {
std::swap(this->type_id, old.type_id); using std::swap;
std::swap(this->data, old.data);
swap(this->type_id, old.type_id);
swap(this->data, old.data);
   
return *this; return *this;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment