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
489e1107
Commit
489e1107
authored
6 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/WritableBuffer: add ConstBuffer cast operator
parent
5e2af15e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+10
-1
No files found.
src/util/WritableBuffer.hxx
View file @
489e1107
/*
/*
* Copyright (C) 2013-201
7
Max Kellermann <max.kellermann@gmail.com>
* Copyright (C) 2013-201
8
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#ifndef WRITABLE_BUFFER_HXX
#ifndef WRITABLE_BUFFER_HXX
#define WRITABLE_BUFFER_HXX
#define WRITABLE_BUFFER_HXX
#include "ConstBuffer.hxx"
#include "Compiler.h"
#include "Compiler.h"
#include <cstddef>
#include <cstddef>
...
@@ -60,6 +61,10 @@ struct WritableBuffer<void> {
...
@@ -60,6 +61,10 @@ struct WritableBuffer<void> {
constexpr
WritableBuffer
(
pointer_type
_data
,
size_type
_size
)
constexpr
WritableBuffer
(
pointer_type
_data
,
size_type
_size
)
:
data
(
_data
),
size
(
_size
)
{}
:
data
(
_data
),
size
(
_size
)
{}
constexpr
operator
ConstBuffer
<
void
>
()
const
noexcept
{
return
{
data
,
size
};
}
constexpr
bool
IsNull
()
const
{
constexpr
bool
IsNull
()
const
{
return
data
==
nullptr
;
return
data
==
nullptr
;
}
}
...
@@ -113,6 +118,10 @@ struct WritableBuffer {
...
@@ -113,6 +118,10 @@ struct WritableBuffer {
constexpr
WritableBuffer
(
T
(
&
_data
)[
_size
])
constexpr
WritableBuffer
(
T
(
&
_data
)[
_size
])
:
data
(
_data
),
size
(
_size
)
{}
:
data
(
_data
),
size
(
_size
)
{}
constexpr
operator
ConstBuffer
<
T
>
()
const
noexcept
{
return
{
data
,
size
};
}
/**
/**
* Cast a WritableBuffer<void> to a WritableBuffer<T>,
* Cast a WritableBuffer<void> to a WritableBuffer<T>,
* rounding down to the next multiple of T's size.
* rounding down to the next multiple of T's size.
...
...
This diff is collapsed.
Click to expand it.
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