@@ -20,17 +20,18 @@ class Manager;
20
20
namespace impl {
21
21
22
22
template <class T >
23
- auto NameRegistrationFromComponentType () -> decltype(std::string{T::kName }) {
24
- return std::string{T::kName };
23
+ auto NameRegistrationFromComponentType ()
24
+ -> decltype(std::string_view{T::kName }) {
25
+ return std::string_view{T::kName };
25
26
}
26
27
27
28
template <class T , class ... Args>
28
29
auto NameRegistrationFromComponentType (Args...) {
29
30
static_assert (!sizeof (T),
30
31
" Component does not have a 'kName' member convertible to "
31
- " std::string . You have to explicitly specify the name: "
32
+ " std::string_view . You have to explicitly specify the name: "
32
33
" component_list.Append<T>(name)." );
33
- return std::string {};
34
+ return std::string_view {};
34
35
}
35
36
36
37
using ComponentBaseFactory =
@@ -138,7 +139,7 @@ class ComponentList final {
138
139
139
140
// / Appends a component with a provided component name.
140
141
template <typename Component>
141
- ComponentList& Append (std::string name) &;
142
+ ComponentList& Append (std::string_view name) &;
142
143
143
144
// / Merges components from `other` into `*this`.
144
145
ComponentList& AppendComponentList (ComponentList&& other) &;
@@ -176,9 +177,9 @@ ComponentList& ComponentList::Append() & {
176
177
}
177
178
178
179
template <typename Component>
179
- ComponentList& ComponentList::Append (std::string name) & {
180
+ ComponentList& ComponentList::Append (std::string_view name) & {
180
181
using Adder = impl::ComponentAdder<Component>;
181
- auto adder = std::make_unique<const Adder>(std::move ( name) );
182
+ auto adder = std::make_unique<const Adder>(std::string{ name} );
182
183
return Append (std::move (adder));
183
184
}
184
185
0 commit comments