Skip to content

Commit afc4ef8

Browse files
authored
Merge pull request #928 from niermann999/fix-type-printing
fix: Type printing
2 parents 4047edc + 84e1383 commit afc4ef8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core/include/detray/utils/type_list.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ std::string get_name(bool full = false) {
165165
// Remove the template argument list
166166
dvector<std::string> tokens{};
167167
for (const auto t : std::views::split(tp_str, '<')) {
168-
tokens.emplace_back(t.begin(), t.end());
168+
// The std::string constructor does not work with std::sentinel_t
169+
tokens.emplace_back(std::string_view(t.begin(), t.end()));
169170
}
170171

171172
// Split a the first ocurrence of '<'
@@ -174,7 +175,7 @@ std::string get_name(bool full = false) {
174175

175176
// Strip the namespaces and qualifiers
176177
for (const auto t : std::views::split(tp_str, ':')) {
177-
tokens.emplace_back(t.begin(), t.end());
178+
tokens.emplace_back(std::string_view(t.begin(), t.end()));
178179
}
179180

180181
// Split at the last occurrence of ':'

tests/unit_tests/cpu/utils/type_list.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// Google Test include(s).
1212
#include <gtest/gtest.h>
1313

14+
// System include(s)
15+
#include <iostream>
16+
1417
// Test type list implementation
1518
GTEST_TEST(detray_utils, type_list) {
1619
using namespace detray;
@@ -37,6 +40,10 @@ GTEST_TEST(detray_utils, type_list) {
3740
"Failed access type");
3841

3942
types::print<list>();
40-
4143
types::print<list>(false);
44+
45+
// Print with template params
46+
std::cout << types::get_name<list>(true) << std::endl;
47+
// Print without template params
48+
std::cout << types::get_name<list>() << std::endl;
4249
}

0 commit comments

Comments
 (0)