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
5e67443a
Commit
5e67443a
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: always enable assertions
parent
17858143
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
44 deletions
+3
-44
ConstBuffer.hxx
src/util/ConstBuffer.hxx
+1
-22
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+2
-22
No files found.
src/util/ConstBuffer.hxx
View file @
5e67443a
...
...
@@ -32,11 +32,8 @@
#include "Compiler.h"
#include <cstddef>
#ifndef NDEBUG
#include <cassert>
#
endif
#
include <cstddef>
template
<
typename
T
>
struct
ConstBuffer
;
...
...
@@ -139,9 +136,7 @@ struct ConstBuffer {
*/
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
);
#endif
return
FromVoidFloor
(
other
);
}
...
...
@@ -192,9 +187,7 @@ struct ConstBuffer {
}
constexpr
reference
operator
[](
size_type
i
)
const
noexcept
{
#ifndef NDEBUG
assert
(
i
<
size
);
#endif
return
data
[
i
];
}
...
...
@@ -204,9 +197,7 @@ struct ConstBuffer {
* be empty.
*/
constexpr
reference
front
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
return
data
[
0
];
}
...
...
@@ -215,9 +206,7 @@ struct ConstBuffer {
* be empty.
*/
constexpr
reference
back
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
return
data
[
size
-
1
];
}
...
...
@@ -226,9 +215,7 @@ struct ConstBuffer {
* not actually modify the buffer). Buffer must not be empty.
*/
constexpr
void
pop_front
()
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
++
data
;
--
size
;
...
...
@@ -239,9 +226,7 @@ struct ConstBuffer {
* not actually modify the buffer). Buffer must not be empty.
*/
constexpr
void
pop_back
()
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
--
size
;
}
...
...
@@ -257,9 +242,7 @@ struct ConstBuffer {
}
constexpr
void
skip_front
(
size_type
n
)
noexcept
{
#ifndef NDEBUG
assert
(
size
>=
n
);
#endif
data
+=
n
;
size
-=
n
;
...
...
@@ -270,10 +253,8 @@ struct ConstBuffer {
* size attribute to retain the old end address.
*/
void
MoveFront
(
pointer
new_data
)
noexcept
{
#ifndef NDEBUG
assert
(
IsNull
()
==
(
new_data
==
nullptr
));
assert
(
new_data
<=
end
());
#endif
size
=
end
()
-
new_data
;
data
=
new_data
;
...
...
@@ -284,10 +265,8 @@ struct ConstBuffer {
* size).
*/
void
SetEnd
(
pointer
new_end
)
noexcept
{
#ifndef NDEBUG
assert
(
IsNull
()
==
(
new_end
==
nullptr
));
assert
(
new_end
>=
begin
());
#endif
size
=
new_end
-
data
;
}
...
...
src/util/WritableBuffer.hxx
View file @
5e67443a
...
...
@@ -33,11 +33,8 @@
#include "ConstBuffer.hxx"
#include "Compiler.h"
#include <cstddef>
#ifndef NDEBUG
#include <cassert>
#
endif
#
include <cstddef>
template
<
typename
T
>
struct
WritableBuffer
;
...
...
@@ -140,14 +137,9 @@ struct WritableBuffer {
* the assertion below ensures that the size is a multiple of
* sizeof(T).
*/
#ifdef NDEBUG
constexpr
#endif
static
WritableBuffer
<
T
>
FromVoid
(
WritableBuffer
<
void
>
other
)
noexcept
{
static
constexpr
WritableBuffer
<
T
>
FromVoid
(
WritableBuffer
<
void
>
other
)
noexcept
{
static_assert
(
sizeof
(
T
)
>
0
,
"Empty base type"
);
#ifndef NDEBUG
assert
(
other
.
size
%
sizeof
(
T
)
==
0
);
#endif
return
FromVoidFloor
(
other
);
}
...
...
@@ -189,9 +181,7 @@ struct WritableBuffer {
}
constexpr
reference
operator
[](
size_type
i
)
const
noexcept
{
#ifndef NDEBUG
assert
(
i
<
size
);
#endif
return
data
[
i
];
}
...
...
@@ -201,9 +191,7 @@ struct WritableBuffer {
* be empty.
*/
constexpr
reference
front
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
return
data
[
0
];
}
...
...
@@ -212,9 +200,7 @@ struct WritableBuffer {
* be empty.
*/
constexpr
reference
back
()
const
noexcept
{
#ifndef NDEBUG
assert
(
!
empty
());
#endif
return
data
[
size
-
1
];
}
...
...
@@ -250,9 +236,7 @@ struct WritableBuffer {
}
constexpr
void
skip_front
(
size_type
n
)
noexcept
{
#ifndef NDEBUG
assert
(
size
>=
n
);
#endif
data
+=
n
;
size
-=
n
;
...
...
@@ -263,10 +247,8 @@ struct WritableBuffer {
* size attribute to retain the old end address.
*/
void
MoveFront
(
pointer
new_data
)
noexcept
{
#ifndef NDEBUG
assert
(
IsNull
()
==
(
new_data
==
nullptr
));
assert
(
new_data
<=
end
());
#endif
size
=
end
()
-
new_data
;
data
=
new_data
;
...
...
@@ -277,10 +259,8 @@ struct WritableBuffer {
* size).
*/
void
SetEnd
(
pointer
new_end
)
noexcept
{
#ifndef NDEBUG
assert
(
IsNull
()
==
(
new_end
==
nullptr
));
assert
(
new_end
>=
begin
());
#endif
size
=
new_end
-
data
;
}
...
...
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