Skip to content

Commit cafffa7

Browse files
committed
make e_member_presence bitflags
1 parent 65e649f commit cafffa7

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

include/nbl/builtin/hlsl/member_test_macros.hlsl

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ namespace hlsl
1717
namespace impl
1818
{
1919

20-
template<class T, bool C>
21-
struct is_const_helper : bool_constant<C>
22-
{
23-
using type = T;
24-
NBL_CONSTEXPR_STATIC_INLINE bool is_constant = is_const<T>::value;
25-
};
26-
2720
enum e_member_presence
2821
{
29-
absent = 0,
30-
non_static = 1,
31-
as_static = 2,
32-
static_constexpr = 3,
22+
is_present = 1<<0,
23+
is_static = 1<<1,
24+
is_const = 1<<2,
3325
};
3426

3527
template<class T>
@@ -55,16 +47,16 @@ namespace hlsl \
5547
{ \
5648
namespace impl { \
5749
template<class T, class=void> \
58-
struct is_static_member_##a: false_type {NBL_CONSTEXPR_STATIC_INLINE bool is_constant = false; }; \
50+
struct is_static_member_##a: false_type { }; \
5951
template<class T> \
60-
struct is_static_member_##a<T,typename enable_if<!is_same<decltype(T::a),void>::value,void>::type>: is_const_helper<decltype(T::a), true> {}; \
52+
struct is_static_member_##a<T,typename enable_if<!is_same<decltype(T::a),void>::value,void>::type> : true_type { }; \
6153
template<class T, class=void> \
62-
struct is_member_##a: false_type {NBL_CONSTEXPR_STATIC_INLINE bool is_constant = false; using type = void; }; \
54+
struct is_member_##a: false_type { using type = void; }; \
6355
template<class T> \
64-
struct is_member_##a<T,typename enable_if<!is_same<decltype(declval<T>().a),void>::value,void>::type> : is_const_helper<decltype(declval<T>().a), true>{}; \
56+
struct is_member_##a<T,typename enable_if<!is_same<decltype(declval<T>().a),void>::value,void>::type> : true_type { using type = decltype(declval<T>().a); }; \
6557
} \
6658
template<class T> \
67-
struct has_member_##a { NBL_CONSTEXPR_STATIC_INLINE e_member_presence value = (e_member_presence)(impl::is_member_##a<T>::value + impl::is_static_member_##a<T>::value + impl::is_static_member_##a<T>::is_constant); }; \
59+
struct has_member_##a { NBL_CONSTEXPR_STATIC_INLINE e_member_presence value = (e_member_presence)(impl::is_member_##a<T>::value + 2*impl::is_static_member_##a<T>::value + 4*is_const<typename impl::is_member_##a<T>::type>::value); }; \
6860
template<class T, class F> struct has_member_##a##_with_type : bool_constant<has_member_##a<T>::value && is_same<typename impl::is_member_##a<T>::type, F>::value> {}; \
6961
} \
7062
}

0 commit comments

Comments
 (0)