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
7namespace kuzu {
8namespace common {
9
10template<typename FROM, typename TO>
11TO 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
#define KU_ASSERT(condition)
Definition assert.h:19
TO ku_dynamic_cast(FROM old)
Definition cast.h:11
Definition alter_type.h:5