File tree 4 files changed +57
-40
lines changed
4 files changed +57
-40
lines changed Original file line number Diff line number Diff line change 12
12
#include " detray/definitions/containers.hpp"
13
13
#include " detray/definitions/detail/qualifiers.hpp"
14
14
#include " detray/definitions/indexing.hpp"
15
- #include " detray/utils/string_view_concat .hpp"
15
+ #include " detray/utils/string_helpers .hpp"
16
16
17
17
// System include(s)
18
18
#include < limits>
@@ -37,7 +37,7 @@ class unbounded {
37
37
static constexpr std::string_view name_prefix = " unbounded " ;
38
38
39
39
// / The name for this shape
40
- static constexpr string_view_concat2 name{name_prefix, shape::name};
40
+ static constexpr utils:: string_view_concat2 name{name_prefix, shape::name};
41
41
42
42
// / Local coordinate frame for boundary checks
43
43
template <concepts::algebra algebra_t >
Original file line number Diff line number Diff line change
1
+ /* * Detray library, part of the ACTS project (R&D line)
2
+ *
3
+ * (c) 2022-2024 CERN for the benefit of the ACTS project
4
+ *
5
+ * Mozilla Public License Version 2.0
6
+ */
7
+
8
+ #pragma once
9
+
10
+ // Project include(s)
11
+ #include " detray/definitions/containers.hpp"
12
+
13
+ // System include(s)
14
+ #include < ranges>
15
+ #include < string>
16
+ #include < string_view>
17
+
18
+ namespace detray ::utils {
19
+
20
+ // / @brief Convenience class to statically concatenate two string views.
21
+ struct string_view_concat2 {
22
+ std::string_view s1;
23
+ std::string_view s2;
24
+
25
+ explicit operator std::string () const {
26
+ return std::string (s1) + std::string (s2);
27
+ }
28
+ };
29
+
30
+ // / Split string @param input at every occurence of @param delim
31
+ inline dvector<std::string> split_at_delim (const std::string &input,
32
+ const char delim) {
33
+ dvector<std::string> tokens{};
34
+
35
+ for (const auto char_range : std::views::split (input, delim)) {
36
+ std::string s{" " };
37
+ // TODO: Remove when range constructor becomes available in c++23
38
+ for (const char c : char_range) {
39
+ s.push_back (c);
40
+ }
41
+ tokens.push_back (std::move (s));
42
+ }
43
+
44
+ return tokens;
45
+ }
46
+
47
+ } // namespace detray::utils
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 8
8
#pragma once
9
9
10
10
// Project include(s)
11
+ #include " detray/utils/string_helpers.hpp"
11
12
#include " detray/utils/tuple.hpp"
12
13
#include " detray/utils/type_traits.hpp"
13
14
14
15
// System include(s)
15
- #include < ranges>
16
16
#include < string>
17
17
#include < string_view>
18
18
#include < type_traits>
@@ -162,23 +162,16 @@ std::string get_name(bool full = false) {
162
162
return tp_str;
163
163
}
164
164
165
- // Remove the template argument list
166
- dvector<std::string> tokens{};
167
- for (const auto t : std::views::split (tp_str, ' <' )) {
168
- // The std::string constructor does not work with std::sentinel_t
169
- tokens.emplace_back (std::string_view (t.begin (), t.end ()));
170
- }
171
-
172
- // Split a the first ocurrence of '<'
165
+ // Remove template parameter list by removing everything behind the first
166
+ // occurrence of '<'
167
+ auto tokens = detray::utils::split_at_delim (tp_str, ' <' );
173
168
tp_str = tokens.front ();
174
- tokens.clear ();
175
169
176
- // Strip the namespaces and qualifiers
177
- for (const auto t : std::views::split (tp_str, ' :' )) {
178
- tokens.emplace_back (std::string_view (t.begin (), t.end ()));
179
- }
170
+ tokens.clear ();
180
171
181
- // Split at the last occurrence of ':'
172
+ // Strip the namespaces by removing everything before the last occurrence of
173
+ // ':'
174
+ tokens = detray::utils::split_at_delim (tp_str, ' :' );
182
175
return tokens.back ();
183
176
}
184
177
You can’t perform that action at this time.
0 commit comments