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
e74e1256
Commit
e74e1256
authored
Jul 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Cast: fix indent
parent
96abd70c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Cast.hxx
src/util/Cast.hxx
+4
-4
No files found.
src/util/Cast.hxx
View file @
e74e1256
...
@@ -38,21 +38,21 @@
...
@@ -38,21 +38,21 @@
static
constexpr
void
*
static
constexpr
void
*
OffsetPointer
(
void
*
p
,
ptrdiff_t
offset
)
OffsetPointer
(
void
*
p
,
ptrdiff_t
offset
)
{
{
return
(
char
*
)
p
+
offset
;
return
(
char
*
)
p
+
offset
;
}
}
template
<
typename
T
,
typename
U
>
template
<
typename
T
,
typename
U
>
static
constexpr
T
*
static
constexpr
T
*
OffsetCast
(
U
*
p
,
ptrdiff_t
offset
)
OffsetCast
(
U
*
p
,
ptrdiff_t
offset
)
{
{
return
reinterpret_cast
<
T
*>
(
OffsetPointer
(
p
,
offset
));
return
reinterpret_cast
<
T
*>
(
OffsetPointer
(
p
,
offset
));
}
}
/**
/**
* Cast the given pointer to a struct member to its parent structure.
* Cast the given pointer to a struct member to its parent structure.
*/
*/
#define ContainerCast(p, container, attribute) \
#define ContainerCast(p, container, attribute) \
OffsetCast<container, decltype(((container*)nullptr)->attribute)>
\
OffsetCast<container, decltype(((container*)nullptr)->attribute)>
\
((p), -ptrdiff_t(offsetof(container, attribute)))
((p), -ptrdiff_t(offsetof(container, attribute)))
#endif
#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