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
Pour information : coupure de la forge ce matin entre 6h45 et 7h05 pour une mise à jour de sécurité
Open sidebar
Gauthier Quesnel
irritator
Commits
1712ca18
Commit
1712ca18
authored
May 18, 2021
by
Gauthier Quesnel
Browse files
core: add emplace function in double flat list
parent
1e77753f
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/include/irritator/core.hpp
View file @
1712ca18
...
...
@@ -1604,6 +1604,8 @@ public:
std
::
swap
(
list
,
other
.
list
);
std
::
swap
(
node
,
other
.
node
);
}
friend
class
flat_double_list
<
T
>
;
};
class
const_iterator
...
...
@@ -1694,6 +1696,8 @@ public:
std
::
swap
(
list
,
other
.
list
);
std
::
swap
(
node
,
other
.
node
);
}
friend
class
flat_double_list
<
T
>
;
};
private:
...
...
@@ -1814,6 +1818,33 @@ public:
return
m_back
->
value
;
}
/**
* @brief Inserts a new element into the container directly before pos.
* @tparam ...Args
* @param pos
* @param ...args
* @return
*/
template
<
typename
...
Args
>
iterator
emplace
(
iterator
pos
,
Args
&&
...
args
)
noexcept
{
if
(
!
pos
.
node
)
return
emplace_back
(
std
::
forward
<
Args
>
(
args
)...);
if
(
!
pos
.
node
->
prev
)
return
emplace_front
(
std
::
forward
<
Args
>
(
args
)...);
node_type
*
new_node
=
m_allocator
->
alloc
();
new
(
&
new_node
->
value
)
T
(
std
::
forward
<
Args
>
(
args
)...);
++
m_size
;
new_node
->
prev
=
pos
.
node
->
prev
;
new_node
->
next
=
pos
.
node
;
pos
.
node
->
prev
->
next
=
new_node
;
pos
.
node
->
prev
=
new_node
;
return
iterator
(
this
,
new_node
);
}
template
<
typename
...
Args
>
iterator
emplace_front
(
Args
&&
...
args
)
noexcept
{
...
...
lib/test/public-api.cpp
View file @
1712ca18
...
...
@@ -597,6 +597,18 @@ main()
--
it
;
expect
(
*
it
==
7
);
}
lst
.
emplace
(
lst
.
begin
(),
10
);
expect
(
*
lst
.
begin
()
==
10
);
{
auto
it
=
lst
.
begin
();
++
it
;
it
=
lst
.
emplace
(
it
,
11
);
expect
(
*
it
==
11
);
expect
(
*
lst
.
begin
()
==
10
);
}
};
"data_array_api"
_test
=
[]
{
...
...
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