Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Koniarik
emlabcpp
Commits
1759d172
Commit
1759d172
authored
Dec 26, 2021
by
Jan Koniarik
Browse files
slight improvements to circular buffer
parent
37b5d1b1
Pipeline
#105449
passed with stage
in 49 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
include/emlabcpp/static_circular_buffer.h
View file @
1759d172
...
...
@@ -49,33 +49,28 @@ public:
static_circular_buffer
()
=
default
;
static_circular_buffer
(
const
static_circular_buffer
&
other
)
{
for
(
size_type
i
=
0
;
i
<
other
.
size
();
++
i
)
{
push_back
(
other
[
i
]
);
}
copy_from
(
other
);
}
static_circular_buffer
(
static_circular_buffer
&&
other
)
noexcept
{
while
(
!
other
.
empty
()
)
{
push_back
(
other
.
pop_front
()
);
}
move_from
(
std
::
move
(
other
)
);
}
static_circular_buffer
&
operator
=
(
const
static_circular_buffer
&
other
)
{
if
(
this
!=
&
other
)
{
this
->~
static_circular_buffe
r
();
::
new
(
this
)
static_circular_buffer
(
other
);
clea
r
();
copy_from
(
other
);
}
return
*
this
;
}
static_circular_buffer
&
operator
=
(
static_circular_buffer
&&
other
)
noexcept
{
if
(
this
!=
&
other
)
{
this
->~
static_circular_buffe
r
();
::
new
(
this
)
static_circular_buffer
(
std
::
move
(
other
)
);
clea
r
();
move_from
(
std
::
move
(
other
)
);
}
return
*
this
;
}
// methods for handling the front side of the circular buffer
[[
nodiscard
]]
iterator
begin
()
...
...
@@ -252,6 +247,20 @@ private:
}
}
void
copy_from
(
const
static_circular_buffer
&
other
)
{
for
(
size_type
i
=
0
;
i
<
other
.
size
();
++
i
)
{
emplace_back
(
other
[
i
]
);
}
}
void
move_from
(
const
static_circular_buffer
&
other
)
{
for
(
size_type
i
=
0
;
i
<
other
.
size
();
++
i
)
{
emplace_back
(
std
::
move
(
other
[
i
]
)
);
}
}
// Use this only when moving the indexes in the circular buffer - bullet-proof.
[[
nodiscard
]]
constexpr
auto
next
(
size_type
i
)
const
{
...
...
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