Skip to content

Commit a590338

Browse files
committed
Add files via upload
1 parent e6a51c2 commit a590338

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (C) 2024 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_
6+
7+
8+
#include <nbl/builtin/hlsl/type_traits.hlsl>
9+
10+
11+
namespace nbl
12+
{
13+
namespace hlsl
14+
{
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+
46+
template<typename T>
47+
const static bool always_true = true;
48+
#ifndef __HLSL_VERSION
49+
50+
template<class T>
51+
std::add_rvalue_reference_t<T> declval() noexcept
52+
{
53+
static_assert(false,"Actually calling declval is ill-formed.");
54+
}
55+
56+
#else
57+
58+
namespace experimental
59+
{
60+
61+
template<class T>
62+
T declval() {}
63+
64+
}
65+
66+
#endif
67+
}
68+
}
69+
70+
#endif

0 commit comments

Comments
 (0)