Kùzu C++ API
Loading...
Searching...
No Matches
cast.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <typeinfo>
4
5
#include "
assert.h
"
6
7
namespace
kuzu
{
8
namespace
common {
9
10
template
<
typename
FROM,
typename
TO>
11
TO
ku_dynamic_cast
(FROM old) {
12
#if defined(KUZU_RUNTIME_CHECKS) || !defined(NDEBUG)
13
try
{
14
TO newVal =
dynamic_cast<
TO
>
(old);
15
if
constexpr
(std::is_pointer<FROM>()) {
16
KU_ASSERT
(newVal !=
nullptr
);
17
}
18
return
newVal;
19
}
catch
(std::bad_cast& e) {
20
KU_ASSERT
(
false
);
21
}
22
#else
23
return
reinterpret_cast<
TO
>
(old);
24
#endif
25
}
26
27
}
// namespace common
28
}
// namespace kuzu
assert.h
KU_ASSERT
#define KU_ASSERT(condition)
Definition
assert.h:19
kuzu::common::ku_dynamic_cast
TO ku_dynamic_cast(FROM old)
Definition
cast.h:11
kuzu
Definition
alter_type.h:5
headers
cast.h
Generated by
1.12.0