Skip to content

Commit 856f828

Browse files
committed
merge master, fix conflicts
2 parents fbfde73 + 407051c commit 856f828

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

include/nbl/system/to_string.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#ifndef _NBL_SYSTEM_TO_STRING_INCLUDED_
2+
#define _NBL_SYSTEM_TO_STRING_INCLUDED_
3+
4+
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
5+
6+
namespace nbl
7+
{
8+
namespace system
9+
{
10+
namespace impl
11+
{
12+
13+
template<typename T>
14+
struct to_string_helper
15+
{
16+
static std::string __call(const T& value)
17+
{
18+
return std::to_string(value);
19+
}
20+
};
21+
22+
template<typename T, int16_t N>
23+
struct to_string_helper<hlsl::vector<T, N>>
24+
{
25+
static std::string __call(const hlsl::vector<T, N>& value)
26+
{
27+
std::stringstream output;
28+
output << "{ ";
29+
for (int i = 0; i < N; ++i)
30+
{
31+
output << to_string_helper<T>::__call(value[i]);
32+
33+
if (i < N - 1)
34+
output << ", ";
35+
}
36+
output << " }";
37+
38+
return output.str();
39+
}
40+
};
41+
42+
}
43+
44+
template<typename T>
45+
std::string to_string(T value)
46+
{
47+
return impl::to_string_helper<T>::__call(value);
48+
}
49+
}
50+
}
51+
52+
#endif

0 commit comments

Comments
 (0)