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

@@ -10,11 +10,11 @@
#include <functional>
#include <string_view>
#include <thread>
#include <type_traits>
#include <utility>
#include <hal/Types.h>
#include <units/time.h>
#include <wpi/concepts.h>
#include <wpi/mutex.h>
namespace frc {
@@ -36,9 +36,8 @@ class Notifier {
*/
explicit Notifier(std::function<void()> handler);
template <
typename Callable, typename Arg, typename... Args,
typename = std::enable_if_t<std::is_invocable_v<Callable, Arg, Args...>>>
template <typename Callable, typename Arg, typename... Args>
requires std::invocable<Callable, Arg, Args...>
Notifier(Callable&& f, Arg&& arg, Args&&... args)
: Notifier(std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
std::forward<Args>(args)...)) {}
@@ -59,6 +58,7 @@ class Notifier {
explicit Notifier(int priority, std::function<void()> handler);
template <typename Callable, typename Arg, typename... Args>
requires std::invocable<Callable, Arg, Args...>
Notifier(int priority, Callable&& f, Arg&& arg, Args&&... args)
: Notifier(priority,
std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),