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:
Tyler Veness
2023-06-07 09:50:09 -07:00
committed by GitHub
parent d57d1a4598
commit 91cbcea841
42 changed files with 397 additions and 361 deletions

View File

@@ -12,6 +12,8 @@
#include <memory>
#include <utility>
#include <wpi/concepts.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -44,11 +46,11 @@ class RepeatCommand : public CommandHelper<CommandBase, RepeatCommand> {
*
* @param command the command to run repeatedly
*/
template <class T, typename = std::enable_if_t<std::is_base_of_v<
Command, std::remove_reference_t<T>>>>
template <std::derived_from<Command> T>
// NOLINTNEXTLINE (bugprone-forwarding-reference-overload)
explicit RepeatCommand(T&& command)
: RepeatCommand(std::make_unique<std::remove_reference_t<T>>(
std::forward<T>(command))) {}
: RepeatCommand(
std::make_unique<std::decay_t<T>>(std::forward<T>(command))) {}
RepeatCommand(RepeatCommand&& other) = default;