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
9dc5335e
Commit
9dc5335e
authored
Mar 01, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/{Const,Writable}Buffer: add template specialization for "void"
Omit a few methods that are not applicable.
parent
d333de19
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
ConstBuffer.hxx
src/util/ConstBuffer.hxx
+34
-0
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+34
-0
No files found.
src/util/ConstBuffer.hxx
View file @
9dc5335e
...
@@ -38,6 +38,40 @@
...
@@ -38,6 +38,40 @@
#include <assert.h>
#include <assert.h>
#endif
#endif
template
<
typename
T
>
struct
ConstBuffer
;
template
<>
struct
ConstBuffer
<
void
>
{
typedef
size_t
size_type
;
typedef
const
void
*
pointer_type
;
typedef
pointer_type
const_pointer_type
;
typedef
pointer_type
iterator
;
typedef
pointer_type
const_iterator
;
pointer_type
data
;
size_type
size
;
ConstBuffer
()
=
default
;
constexpr
ConstBuffer
(
std
::
nullptr_t
)
:
data
(
nullptr
),
size
(
0
)
{}
constexpr
ConstBuffer
(
pointer_type
_data
,
size_type
_size
)
:
data
(
_data
),
size
(
_size
)
{}
constexpr
static
ConstBuffer
Null
()
{
return
ConstBuffer
(
nullptr
,
0
);
}
constexpr
bool
IsNull
()
const
{
return
data
==
nullptr
;
}
constexpr
bool
IsEmpty
()
const
{
return
size
==
0
;
}
};
/**
/**
* A reference to a memory area that is read-only.
* A reference to a memory area that is read-only.
*/
*/
...
...
src/util/WritableBuffer.hxx
View file @
9dc5335e
...
@@ -38,6 +38,40 @@
...
@@ -38,6 +38,40 @@
#include <assert.h>
#include <assert.h>
#endif
#endif
template
<
typename
T
>
struct
WritableBuffer
;
template
<>
struct
WritableBuffer
<
void
>
{
typedef
size_t
size_type
;
typedef
void
*
pointer_type
;
typedef
const
void
*
const_pointer_type
;
typedef
pointer_type
iterator
;
typedef
const_pointer_type
const_iterator
;
pointer_type
data
;
size_type
size
;
WritableBuffer
()
=
default
;
constexpr
WritableBuffer
(
std
::
nullptr_t
)
:
data
(
nullptr
),
size
(
0
)
{}
constexpr
WritableBuffer
(
pointer_type
_data
,
size_type
_size
)
:
data
(
_data
),
size
(
_size
)
{}
constexpr
static
WritableBuffer
Null
()
{
return
{
nullptr
,
0
};
}
constexpr
bool
IsNull
()
const
{
return
data
==
nullptr
;
}
constexpr
bool
IsEmpty
()
const
{
return
size
==
0
;
}
};
/**
/**
* A reference to a memory area that is writable.
* A reference to a memory area that is writable.
*
*
...
...
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