mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user