mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Replace SFINAE with concepts (#5361)
Concepts are cleaner to use and result in much better error messages for incorrect template use.
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/concepts.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
@@ -43,17 +43,15 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
* @param commands the map of commands to choose from
|
||||
* @param selector the selector to determine which command to run
|
||||
*/
|
||||
template <class... Types,
|
||||
typename = std::enable_if_t<std::conjunction_v<
|
||||
std::is_base_of<Command, std::remove_reference_t<Types>>...>>>
|
||||
template <std::derived_from<Command>... Commands>
|
||||
explicit SelectCommand(std::function<Key()> selector,
|
||||
std::pair<Key, Types>... commands)
|
||||
std::pair<Key, Commands>... commands)
|
||||
: m_selector{std::move(selector)} {
|
||||
std::vector<std::pair<Key, std::unique_ptr<Command>>> foo;
|
||||
|
||||
((void)foo.emplace_back(commands.first,
|
||||
std::make_unique<std::remove_reference_t<Types>>(
|
||||
std::move(commands.second))),
|
||||
((void)foo.emplace_back(
|
||||
commands.first,
|
||||
std::make_unique<std::decay_t<Commands>>(std::move(commands.second))),
|
||||
...);
|
||||
|
||||
for (auto&& command : foo) {
|
||||
|
||||
Reference in New Issue
Block a user