Nebula
Loading...
Searching...
No Matches
typepunning.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
14#include "core/types.h"
15
16//------------------------------------------------------------------------------
17namespace Util
18{
19
20template<typename A, typename B>
22{
23 union
24 {
25 A *a;
26 B *b;
27 } pun;
28 pun.b = &v;
29 return *pun.a;
30}
31
32template<typename A, typename B>
33const A& TypePunning(const B &v)
34{
35 union
36 {
37 const A *a;
38 const B *b;
39 } pun;
40 pun.b = &v;
41 return *pun.a;
42}
43
44} // namespace Util
45//------------------------------------------------------------------------------
46
A pinned array is an array which manages its own virtual memory.
Definition String.cs:6
A & TypePunning(B &v)
Definition typepunning.h:21