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
f8da8b02
Commit
f8da8b02
authored
Jul 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Cast: add const overloads
parent
393cb7fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
Cast.hxx
src/util/Cast.hxx
+16
-0
No files found.
src/util/Cast.hxx
View file @
f8da8b02
...
...
@@ -41,6 +41,15 @@ OffsetPointer(void *p, ptrdiff_t offset)
return
(
char
*
)
p
+
offset
;
}
/**
* Offset the given pointer by the specified number of bytes.
*/
static
inline
constexpr
const
void
*
OffsetPointer
(
const
void
*
p
,
ptrdiff_t
offset
)
{
return
(
const
char
*
)
p
+
offset
;
}
template
<
typename
T
,
typename
U
>
static
inline
constexpr
T
*
OffsetCast
(
U
*
p
,
ptrdiff_t
offset
)
...
...
@@ -48,6 +57,13 @@ OffsetCast(U *p, ptrdiff_t offset)
return
reinterpret_cast
<
T
*>
(
OffsetPointer
(
p
,
offset
));
}
template
<
typename
T
,
typename
U
>
static
inline
constexpr
T
*
OffsetCast
(
const
U
*
p
,
ptrdiff_t
offset
)
{
return
reinterpret_cast
<
const
T
*>
(
OffsetPointer
(
p
,
offset
));
}
/**
* Cast the given pointer to a struct member to its parent structure.
*/
...
...
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