Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
910582b5
Commit
910582b5
authored
Mar 24, 2015
by
BRAMAS Berenger
Browse files
Add copy constructor and operator from rvalue objects for the list and vectro
parent
548c9b34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Src/Containers/FList.hpp
View file @
910582b5
...
...
@@ -96,6 +96,34 @@ public:
copy
(
other
);
}
/**
* Copy operator
* This will clear the current list before copying
* @param other the source list
* @return the current list as a reference
*/
FList
&
operator
=
(
FList
&&
other
){
if
(
&
other
!=
this
){
clear
();
root
=
other
.
root
;
size
=
other
.
size
;
other
.
root
=
nullptr
;
other
.
size
=
0
;
}
return
*
this
;
}
/**
* Copy constructor
* @param other the source/original list
*/
FList
(
FList
&&
other
)
:
root
(
nullptr
)
,
size
(
0
)
{
root
=
other
.
root
;
size
=
other
.
size
;
other
.
root
=
nullptr
;
other
.
size
=
0
;
}
/**
* To clear the list
* Size is 0 after calling this function
...
...
Src/Containers/FVector.hpp
View file @
910582b5
...
...
@@ -77,6 +77,20 @@ public:
}
}
/**
* Copy constructor
* @param other original vector
* object must have an copy constructor
*/
FVector
(
FVector
&&
other
)
:
array
(
nullptr
),
capacity
(
0
),
index
(
0
)
{
array
=
other
.
array
;
capacity
=
other
.
capacity
;
index
=
other
.
index
;
other
.
array
=
nullptr
;
other
.
capacity
=
0
;
other
.
index
=
0
;
}
/** Copy operator
* @param other the original vector
* @return this after copying data
...
...
@@ -103,6 +117,23 @@ public:
return
*
this
;
}
/**
*@brief Copy operator
*/
FVector
&
operator
=
(
FVector
&&
other
){
if
(
&
other
!=
this
){
clear
();
delete
[]
reinterpret_cast
<
char
*
>
(
array
);
array
=
other
.
array
;
capacity
=
other
.
capacity
;
index
=
other
.
index
;
other
.
array
=
nullptr
;
other
.
capacity
=
0
;
other
.
index
=
0
;
}
return
(
*
this
);
}
/**
*@brief destructor
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment