Skip to content

Commit 57e5460

Browse files
committed
Update utility.hlsl
1 parent b2f7d3a commit 57e5460

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

include/nbl/builtin/hlsl/utility.hlsl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,41 @@
88
#include <nbl/builtin/hlsl/type_traits.hlsl>
99

1010

11-
// for now we only implement declval
1211
namespace nbl
1312
{
1413
namespace hlsl
1514
{
15+
16+
template<typename T1, typename T2>
17+
struct pair
18+
{
19+
using first_type = T1;
20+
using second_type = T2;
21+
22+
first_type first;
23+
second_type second;
24+
};
25+
26+
template<typename T1, typename T2>
27+
pair<T1, T2> make_pair(T1 f, T2 s)
28+
{
29+
pair<T1, T2> p;
30+
p.first = f;
31+
p.second = s;
32+
return p;
33+
}
34+
35+
template<typename T1, typename T2>
36+
void swap(NBL_REF_ARG(pair<T1, T2>) a, NBL_REF_ARG(pair<T1, T2>) b)
37+
{
38+
T1 temp_first = a.first;
39+
T2 temp_second = a.second;
40+
a.first = b.first;
41+
a.second = b.second;
42+
b.first = temp_first;
43+
b.second = temp_second;
44+
}
45+
1646
template<typename T>
1747
const static bool always_true = true;
1848
#ifndef __HLSL_VERSION

0 commit comments

Comments
 (0)