mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
@@ -6,8 +6,10 @@
|
||||
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -156,13 +158,15 @@ namespace cmd {
|
||||
* @param selector the selector function
|
||||
* @param commands map of commands to select from
|
||||
*/
|
||||
template <typename Key>
|
||||
[[nodiscard]] CommandPtr Select(
|
||||
std::function<Key()> selector,
|
||||
std::vector<std::pair<Key, CommandPtr>> commands) {
|
||||
return SelectCommand(std::move(selector),
|
||||
CommandPtr::UnwrapVector(std::move(commands)))
|
||||
.ToPtr();
|
||||
template <typename Key, class... Types>
|
||||
[[nodiscard]] CommandPtr Select(std::function<Key()> selector,
|
||||
std::pair<Key, Types>&&... commands) {
|
||||
std::vector<std::pair<Key, std::unique_ptr<Command>>> vec;
|
||||
|
||||
((void)vec.emplace_back(commands.first, std::move(commands.second).Unwrap()),
|
||||
...);
|
||||
|
||||
return SelectCommand(std::move(selector), std::move(vec)).ToPtr();
|
||||
}
|
||||
|
||||
// Command Groups
|
||||
|
||||
Reference in New Issue
Block a user