File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 6
6
7
7
#include < functional>
8
8
#include < initializer_list>
9
+ #include < memory>
9
10
#include < span>
10
11
#include < string>
12
+ #include < type_traits>
11
13
#include < utility>
12
14
#include < vector>
13
15
@@ -156,13 +158,15 @@ namespace cmd {
156
158
* @param selector the selector function
157
159
* @param commands map of commands to select from
158
160
*/
159
- template <typename Key>
160
- [[nodiscard]] CommandPtr Select (
161
- std::function<Key()> selector,
162
- std::vector<std::pair<Key, CommandPtr>> commands) {
163
- return SelectCommand (std::move (selector),
164
- CommandPtr::UnwrapVector (std::move (commands)))
165
- .ToPtr ();
161
+ template <typename Key, class ... Types>
162
+ [[nodiscard]] CommandPtr Select (std::function<Key()> selector,
163
+ std::pair<Key, Types>&&... commands) {
164
+ std::vector<std::pair<Key, std::unique_ptr<Command>>> vec;
165
+
166
+ ((void )vec.emplace_back (commands.first , std::move (commands.second ).Unwrap ()),
167
+ ...);
168
+
169
+ return SelectCommand (std::move (selector), std::move (vec)).ToPtr ();
166
170
}
167
171
168
172
// Command Groups
You can’t perform that action at this time.
0 commit comments