Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
17858143
Commit
17858143
authored
Jan 15, 2021
by
Max Kellermann
Committed by
Max Kellermann
Jan 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/{Const,Writable}Buffer: enable `constexpr` on more methods
parent
c44a7b27
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
38 deletions
+16
-38
ConstBuffer.hxx
src/util/ConstBuffer.hxx
+9
-22
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+7
-16
No files found.
src/util/ConstBuffer.hxx
View file @
17858143
...
...
@@ -137,10 +137,7 @@ struct ConstBuffer {
* the assertion below ensures that the size is a multiple of
* sizeof(T).
*/
#ifdef NDEBUG
constexpr
#endif
static
ConstBuffer
<
T
>
FromVoid
(
ConstBuffer
<
void
>
other
)
noexcept
{
constexpr
static
ConstBuffer
<
T
>
FromVoid
(
ConstBuffer
<
void
>
other
)
noexcept
{
static_assert
(
sizeof
(
T
)
>
0
,
"Empty base type"
);
#ifndef NDEBUG
assert
(
other
.
size
%
sizeof
(
T
)
==
0
);
...
...
@@ -170,8 +167,7 @@ struct ConstBuffer {
}
template
<
typename
U
>
gcc_pure
bool
Contains
(
U
&&
u
)
const
noexcept
{
constexpr
bool
Contains
(
U
&&
u
)
const
noexcept
{
for
(
const
auto
&
i
:
*
this
)
if
(
u
==
i
)
return
true
;
...
...
@@ -195,10 +191,7 @@ struct ConstBuffer {
return
data
+
size
;
}
#ifdef NDEBUG
constexpr
#endif
reference
operator
[](
size_type
i
)
const
noexcept
{
constexpr
reference
operator
[](
size_type
i
)
const
noexcept
{
#ifndef NDEBUG
assert
(
i
<
size
);
#endif
...
...
@@ -210,10 +203,7 @@ struct ConstBuffer {
* Returns a reference to the first element. Buffer must not
* be empty.
*/
#ifdef NDEBUG
constexpr
#endif
reference
front
()
const
noexcept
{
constexpr
reference
front
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -224,10 +214,7 @@ struct ConstBuffer {
* Returns a reference to the last element. Buffer must not
* be empty.
*/
#ifdef NDEBUG
constexpr
#endif
reference
back
()
const
noexcept
{
constexpr
reference
back
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -238,7 +225,7 @@ struct ConstBuffer {
* Remove the first element (by moving the head pointer, does
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_front
()
noexcept
{
constexpr
void
pop_front
()
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -251,7 +238,7 @@ struct ConstBuffer {
* Remove the last element (by moving the tail pointer, does
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_back
()
noexcept
{
constexpr
void
pop_back
()
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -263,13 +250,13 @@ struct ConstBuffer {
* Remove the first element and return a reference to it.
* Buffer must not be empty.
*/
reference
shift
()
noexcept
{
constexpr
reference
shift
()
noexcept
{
reference
result
=
front
();
pop_front
();
return
result
;
}
void
skip_front
(
size_type
n
)
noexcept
{
constexpr
void
skip_front
(
size_type
n
)
noexcept
{
#ifndef NDEBUG
assert
(
size
>=
n
);
#endif
...
...
src/util/WritableBuffer.hxx
View file @
17858143
...
...
@@ -188,10 +188,7 @@ struct WritableBuffer {
return
data
+
size
;
}
#ifdef NDEBUG
constexpr
#endif
reference
operator
[](
size_type
i
)
const
noexcept
{
constexpr
reference
operator
[](
size_type
i
)
const
noexcept
{
#ifndef NDEBUG
assert
(
i
<
size
);
#endif
...
...
@@ -203,10 +200,7 @@ struct WritableBuffer {
* Returns a reference to the first element. Buffer must not
* be empty.
*/
#ifdef NDEBUG
constexpr
#endif
reference
front
()
const
noexcept
{
constexpr
reference
front
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -217,10 +211,7 @@ struct WritableBuffer {
* Returns a reference to the last element. Buffer must not
* be empty.
*/
#ifdef NDEBUG
constexpr
#endif
reference
back
()
const
noexcept
{
constexpr
reference
back
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
...
...
@@ -231,7 +222,7 @@ struct WritableBuffer {
* Remove the first element (by moving the head pointer, does
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_front
()
noexcept
{
constexpr
void
pop_front
()
noexcept
{
assert
(
!
empty
());
++
data
;
...
...
@@ -242,7 +233,7 @@ struct WritableBuffer {
* Remove the last element (by moving the tail pointer, does
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_back
()
noexcept
{
constexpr
void
pop_back
()
noexcept
{
assert
(
!
empty
());
--
size
;
...
...
@@ -252,13 +243,13 @@ struct WritableBuffer {
* Remove the first element and return a reference to it.
* Buffer must not be empty.
*/
reference
shift
()
noexcept
{
constexpr
reference
shift
()
noexcept
{
reference
result
=
front
();
pop_front
();
return
result
;
}
void
skip_front
(
size_type
n
)
noexcept
{
constexpr
void
skip_front
(
size_type
n
)
noexcept
{
#ifndef NDEBUG
assert
(
size
>=
n
);
#endif
...
...
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