Loading [MathJax]/jax/output/HTML-CSS/config.js
Photon Engine
2.0.0-beta
A physically based renderer.
Toggle main menu visibility
Home
Components
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
a
b
c
d
e
f
g
h
k
m
p
r
s
t
u
x
y
z
Typedefs
a
b
c
d
e
f
h
i
k
l
m
p
q
r
s
t
v
Enumerations
e
Enumerator
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Typedefs
a
b
c
d
e
f
i
k
m
n
o
p
r
s
t
v
w
Enumerations
Related Symbols
Files
File List
File Members
All
b
c
f
i
k
m
p
s
Functions
Typedefs
Macros
▼
Photon Engine
Home
Components
►
Engine
►
Engine Directories
Bibliography
►
Namespaces
►
Concepts
►
Classes
▼
Files
▼
File List
Documentation
►
Include
▼
Source
►
Actor
►
Api
►
Common
►
Core
►
DataIO
►
EngineEnv
►
Frame
►
Math
►
SDL
▼
Utility
►
Concurrent
►
Debug
►
ByteBuffer.h
►
fixed_map_base.h
►
IMoveOnly.h
►
INoCopyAndMove.h
►
IUninstantiable.h
MemoryArena.cpp
►
MemoryArena.h
MemoryArena.ipp
SemanticVersion.cpp
►
SemanticVersion.h
►
TAnyPtr.h
►
TArrayHeap.h
TArrayHeap.ipp
►
TArrayStack.h
TArrayStack.ipp
►
TArrayVector.h
TArrayVector.ipp
►
TBitFlags.h
TBitFlags.ipp
►
TConstIteratorProxy.h
►
TFixedEnumMap.h
►
TFixedIntegerMap.h
►
TFunction.h
►
Timer.h
►
TIteratorProxy.h
►
traits.h
►
TSortedMap.h
TSortedMap.ipp
►
TSortedVector.h
TSortedVector.ipp
►
TSpan.h
►
TStableIndexDenseVector.h
►
TUniquePtrVector.h
►
utility.h
►
World
►
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
TAnyPtr.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <utility>
4
#include <cstddef>
5
#include <type_traits>
6
#include <typeindex>
7
8
namespace
ph
9
{
10
15
template
<
bool
IS_CONST>
16
class
TAnyPtr
final
17
{
18
public
:
19
TAnyPtr
();
20
21
TAnyPtr
(std::nullptr_t ptr);
22
23
template
<
typename
T>
24
TAnyPtr
(T* ptr);
25
26
template
<
typename
T>
27
auto
*
get
()
const
;
28
29
operator
bool ()
const
;
30
31
template
<
typename
T>
32
operator
T* ()
const
;
33
34
private
:
35
using
PointerType = std::conditional_t<IS_CONST, const void*, void*>;
36
37
PointerType m_pointer;
38
std::type_index m_pointedType;
39
};
40
43
using
AnyConstPtr
=
TAnyPtr<true>
;
44
47
using
AnyNonConstPtr
=
TAnyPtr<false>
;
48
49
template
<
bool
IS_CONST>
50
inline
TAnyPtr<IS_CONST>::TAnyPtr
()
51
:
TAnyPtr
(nullptr)
52
{}
50
inline
TAnyPtr<IS_CONST>::TAnyPtr
() {
…
}
53
54
template
<
bool
IS_CONST>
55
inline
TAnyPtr<IS_CONST>::TAnyPtr
(std::nullptr_t
/* ptr */
)
56
: m_pointer(nullptr)
57
, m_pointedType(typeid(
std
::nullptr_t))
58
{}
55
inline
TAnyPtr<IS_CONST>::TAnyPtr
(std::nullptr_t
/* ptr */
) {
…
}
59
60
template
<
bool
IS_CONST>
61
template
<
typename
T>
62
inline
TAnyPtr<IS_CONST>::TAnyPtr
(T*
const
ptr)
63
: m_pointer(ptr)
64
, m_pointedType(typeid(T))
65
{
66
static_assert
(
sizeof
(T) ==
sizeof
(T),
67
"Input must be a complete type."
);
68
}
62
inline
TAnyPtr<IS_CONST>::TAnyPtr
(T*
const
ptr) {
…
}
69
70
template
<
bool
IS_CONST>
71
template
<
typename
T>
72
inline
auto
*
TAnyPtr<IS_CONST>::get
()
const
73
{
74
// Also handles the case where `const` is explicitly specified in `T`
75
using
ReturnType = std::conditional_t<IS_CONST, const T, T>;
76
77
// Important: type must be exactly equal for the cast to have defined behavior
78
if
(m_pointedType ==
typeid
(T))
79
{
80
return
static_cast<
ReturnType*
>
(m_pointer);
81
}
82
else
83
{
84
return
static_cast<
ReturnType*
>
(
nullptr
);
85
}
86
}
72
inline
auto
*
TAnyPtr<IS_CONST>::get
()
const
{
…
}
87
88
template
<
bool
IS_CONST>
89
inline
TAnyPtr<IS_CONST>::operator
bool ()
const
90
{
91
return
m_pointer !=
nullptr
;
92
}
89
inline
TAnyPtr<IS_CONST>::operator
bool ()
const
{
…
}
93
94
template
<
bool
IS_CONST>
95
template
<
typename
T>
96
inline
TAnyPtr<IS_CONST>::operator
T* ()
const
97
{
98
// Note that we could, of course, write a better return type that matches `IS_CONST`. Here a more
99
// general type `T*` is used, so we could detect potential conversion errors here and provide
100
// a more friendly error message.
101
//
102
static_assert
(!(IS_CONST && !std::is_const_v<T>),
103
"Cannot convert a const pointer to non-const."
);
104
105
return
get<T>();
106
}
96
inline
TAnyPtr<IS_CONST>::operator
T* ()
const
{
…
}
32
operator
T* ()
const
; {
…
}
107
108
}
// end namespace ph
29
operator
bool ()
const
; {
…
}
27
auto
*
get
()
const
; {
…
}
24
TAnyPtr
(T* ptr); {
…
}
21
TAnyPtr
(std::nullptr_t ptr); {
…
}
19
TAnyPtr
(); {
…
}
16
class
TAnyPtr
final {
…
};
ph::TAnyPtr
A type-safe, lightweight wrapper for any raw pointer type. Using std::any with a raw pointer type cou...
Definition
TAnyPtr.h:17
ph::TAnyPtr::get
auto * get() const
Definition
TAnyPtr.h:72
ph::TAnyPtr::TAnyPtr
TAnyPtr(std::nullptr_t ptr)
Definition
TAnyPtr.h:55
ph::TAnyPtr::TAnyPtr
TAnyPtr()
Definition
TAnyPtr.h:50
ph::TAnyPtr::TAnyPtr
TAnyPtr(T *ptr)
Definition
TAnyPtr.h:62
ph
The root for all renderer implementations.
Definition
EEngineProject.h:6
std
Definition
TAABB2D.h:96
Source
Utility
TAnyPtr.h
Generated by
1.11.0