33
44#include < nbl/builtin/hlsl/macros.h>
55
6+ namespace nbl
7+ {
8+ namespace hlsl
9+ {
10+ namespace impl
11+ {
12+ template <typename To, typename From, typename Enabled = void >
13+ struct static_cast_helper
14+ {
15+ static inline To cast (From u)
16+ {
17+ #ifndef __HLSL_VERSION
18+ return static_cast <To>(u);
19+ #else
20+ return To (u);
21+ #endif
22+ }
23+ };
24+ }
25+
26+ template <typename To, typename From>
27+ inline To _static_cast (From v)
28+ {
29+ return impl::static_cast_helper<To, From>::cast (v);
30+ }
31+
32+ }
33+ }
34+
635#ifndef __HLSL_VERSION
736#include < type_traits>
837
1140#define NBL_CONSTEXPR_FUNC constexpr
1241#define NBL_CONSTEXPR_STATIC constexpr static
1342#define NBL_CONSTEXPR_STATIC_INLINE constexpr static inline
43+ #define NBL_CONSTEXPR_INLINE_FUNC constexpr inline
1444#define NBL_CONST_MEMBER_FUNC const
1545
1646namespace nbl ::hlsl
1747{
18- template <typename T, typename U>
19- T _static_cast (U v)
20- {
21- return static_cast <T>(v);
22- }
23-
2448 template <typename T>
2549 using add_reference = std::add_lvalue_reference<T>;
2650
@@ -41,32 +65,28 @@ namespace nbl::hlsl
4165#define NBL_CONSTEXPR_FUNC
4266#define NBL_CONSTEXPR_STATIC const static
4367#define NBL_CONSTEXPR_STATIC_INLINE const static
68+ #define NBL_CONSTEXPR_INLINE_FUNC inline
4469#define NBL_CONST_MEMBER_FUNC
4570
4671namespace nbl
4772{
48- namespace hlsl
49- {
50- template <typename T, typename U>
51- T _static_cast (U v)
52- {
53- return (T)v;
54- }
73+ namespace hlsl
74+ {
5575
5676#if 0 // TODO: for later
57- template<typename T>
58- struct add_reference
59- {
60- using type = ref<T>;
61- };
62- template<typename T>
63- struct add_pointer
64- {
65- using type = ptr<T>;
66- };
77+ template<typename T>
78+ struct add_reference
79+ {
80+ using type = ref<T>;
81+ };
82+ template<typename T>
83+ struct add_pointer
84+ {
85+ using type = ptr<T>;
86+ };
6787#endif
6888
69- }
89+ }
7090}
7191
7292#define NBL_REF_ARG (...) inout __VA_ARGS__
0 commit comments