Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
c44fd562
Commit
c44fd562
authored
Dec 11, 2014
by
BRAMAS Berenger
Browse files
Add operation to the vector to ensure that object without default constructor can be user with it
parent
c503873f
Changes
1
Show whitespace changes
Inline
Side-by-side
Src/Containers/FVector.hpp
View file @
c44fd562
...
@@ -145,13 +145,14 @@ public:
...
@@ -145,13 +145,14 @@ public:
}
}
/** Resize the vector (and change the capacity if needed) */
/** Resize the vector (and change the capacity if needed) */
void
resize
(
const
int
newSize
){
template
<
typename
...
Args
>
void
resize
(
const
int
newSize
,
Args
...
args
){
if
(
index
<
newSize
){
if
(
index
<
newSize
){
if
(
capacity
<
newSize
){
if
(
capacity
<
newSize
){
setCapacity
(
int
(
newSize
*
1.5
));
setCapacity
(
int
(
newSize
*
1.5
));
}
}
while
(
index
!=
newSize
){
while
(
index
!=
newSize
){
new
((
void
*
)
&
array
[
index
])
ObjectType
();
new
((
void
*
)
&
array
[
index
])
ObjectType
(
args
...
);
}
}
}
}
else
{
else
{
...
@@ -215,6 +216,19 @@ public:
...
@@ -215,6 +216,19 @@ public:
new
((
void
*
)
&
array
[
index
++
])
ObjectType
(
inValue
);
new
((
void
*
)
&
array
[
index
++
])
ObjectType
(
inValue
);
}
}
/**
* To Create a new object
*/
template
<
typename
...
Args
>
void
pushNew
(
Args
...
args
){
// if needed, increase the vector
if
(
index
==
capacity
){
setCapacity
(
int
((
capacity
+
1
)
*
1.5
));
}
// add the new element
new
((
void
*
)
&
array
[
index
++
])
ObjectType
(
args
...);
}
/**
/**
* Add one value multiple time
* Add one value multiple time
* @param inValue the new value
* @param inValue the new value
...
...
Write
Preview
Markdown
is supported
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