Skip to content

Commit ba1aca4

Browse files
Merge pull request #631 from theoreticalphysicsftw/cpp_compat_ref
Make NBL_(CONST)_REF_ARG to work with multi-parameter templates.
2 parents 4584838 + 1e096c6 commit ba1aca4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/nbl/builtin/hlsl/cpp_compat.hlsl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ using add_pointer = std::add_pointer<T>;
3131

3232
}
3333

34-
#define NBL_REF_ARG(T) typename nbl::hlsl::add_reference<T>::type
35-
#define NBL_CONST_REF_ARG(T) typename nbl::hlsl::add_reference<std::add_const_t<T>>::type
34+
// We need variadic macro in order to handle multi parameter templates because the
35+
// preprocessor parses the template parameters as different macro parameters.
36+
#define NBL_REF_ARG(...) typename nbl::hlsl::add_reference<__VA_ARGS__>::type
37+
#define NBL_CONST_REF_ARG(...) typename nbl::hlsl::add_reference<std::add_const_t<__VA_ARGS__>>::type
3638

3739
#else
3840

@@ -62,8 +64,8 @@ struct add_pointer
6264
}
6365
}
6466

65-
#define NBL_REF_ARG(T) inout T
66-
#define NBL_CONST_REF_ARG(T) const in T
67+
#define NBL_REF_ARG(...) inout __VA_ARGS__
68+
#define NBL_CONST_REF_ARG(...) const in __VA_ARGS__
6769

6870
#endif
6971

0 commit comments

Comments
 (0)