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 66
77#include < functional>
88#include < initializer_list>
9+ #include < memory>
910#include < span>
1011#include < string>
12+ #include < type_traits>
1113#include < utility>
1214#include < vector>
1315
@@ -156,13 +158,15 @@ namespace cmd {
156158 * @param selector the selector function
157159 * @param commands map of commands to select from
158160 */
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 ();
166170}
167171
168172// Command Groups
You can’t perform that action at this time.
0 commit comments