mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Replace ::value and ::type with _v and _t suffixes (#1885)
This commit is contained in:
committed by
Peter Johnson
parent
a5650b9439
commit
1d8c4d016f
@@ -170,8 +170,8 @@ class CommandScheduler final : public frc::SendableBase, frc::ErrorBase {
|
||||
* @param subsystem the subsystem whose default command will be set
|
||||
* @param defaultCommand the default command to associate with the subsystem
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
void SetDefaultCommand(Subsystem* subsystem, T&& defaultCommand) {
|
||||
if (!defaultCommand.HasRequirement(subsystem)) {
|
||||
wpi_setWPIErrorWithContext(
|
||||
|
||||
@@ -46,9 +46,9 @@ class ConditionalCommand
|
||||
*/
|
||||
template <class T1, class T2,
|
||||
typename = std::enable_if_t<
|
||||
std::is_base_of<Command, std::remove_reference_t<T1>>::value>,
|
||||
std::is_base_of_v<Command, std::remove_reference_t<T1>>>,
|
||||
typename = std::enable_if_t<
|
||||
std::is_base_of<Command, std::remove_reference_t<T2>>::value>>
|
||||
std::is_base_of_v<Command, std::remove_reference_t<T2>>>>
|
||||
ConditionalCommand(T1&& onTrue, T2&& onFalse, std::function<bool()> condition)
|
||||
: ConditionalCommand(std::make_unique<std::remove_reference_t<T1>>(
|
||||
std::forward<T1>(onTrue)),
|
||||
|
||||
@@ -51,7 +51,7 @@ class ParallelDeadlineGroup
|
||||
*/
|
||||
template <class T, class... Types,
|
||||
typename = std::enable_if_t<
|
||||
std::is_base_of<Command, std::remove_reference_t<T>>::value>,
|
||||
std::is_base_of_v<Command, std::remove_reference_t<T>>>,
|
||||
typename = std::enable_if_t<std::conjunction_v<
|
||||
std::is_base_of<Command, std::remove_reference_t<Types>>...>>>
|
||||
explicit ParallelDeadlineGroup(T&& deadline, Types&&... commands) {
|
||||
|
||||
@@ -43,8 +43,8 @@ class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
|
||||
*
|
||||
* @param command the command to run perpetually
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
explicit PerpetualCommand(T&& command)
|
||||
: PerpetualCommand(std::make_unique<std::remove_reference_t<T>>(
|
||||
std::forward<T>(command))) {}
|
||||
|
||||
@@ -56,8 +56,8 @@ class Subsystem {
|
||||
*
|
||||
* @param defaultCommand the default command to associate with this subsystem
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
void SetDefaultCommand(T&& defaultCommand) {
|
||||
CommandScheduler::GetInstance().SetDefaultCommand(
|
||||
this, std::forward<T>(defaultCommand));
|
||||
|
||||
@@ -54,8 +54,8 @@ class Button : public Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Button WhenPressed(T&& command, bool interruptible = true) {
|
||||
WhenActive(std::forward<T>(command), interruptible);
|
||||
return *this;
|
||||
@@ -89,8 +89,8 @@ class Button : public Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The button, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Button WhileHeld(T&& command, bool interruptible = true) {
|
||||
WhileActiveContinous(std::forward<T>(command), interruptible);
|
||||
return *this;
|
||||
@@ -124,8 +124,8 @@ class Button : public Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The button, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Button WhenHeld(T&& command, bool interruptible = true) {
|
||||
WhileActiveOnce(std::forward<T>(command), interruptible);
|
||||
return *this;
|
||||
@@ -152,8 +152,8 @@ class Button : public Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The button, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Button WhenReleased(T&& command, bool interruptible = true) {
|
||||
WhenInactive(std::forward<T>(command), interruptible);
|
||||
return *this;
|
||||
@@ -187,8 +187,8 @@ class Button : public Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The button, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Button ToggleWhenPressed(T&& command, bool interruptible = true) {
|
||||
ToggleWhenActive(std::forward<T>(command), interruptible);
|
||||
return *this;
|
||||
|
||||
@@ -72,8 +72,8 @@ class Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Trigger WhenActive(T&& command, bool interruptible = true) {
|
||||
CommandScheduler::GetInstance().AddButton(
|
||||
[pressedLast = Get(), *this,
|
||||
@@ -120,8 +120,8 @@ class Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Trigger WhileActiveContinous(T&& command, bool interruptible = true) {
|
||||
CommandScheduler::GetInstance().AddButton(
|
||||
[pressedLast = Get(), *this,
|
||||
@@ -169,8 +169,8 @@ class Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Trigger WhileActiveOnce(T&& command, bool interruptible = true) {
|
||||
CommandScheduler::GetInstance().AddButton(
|
||||
[pressedLast = Get(), *this,
|
||||
@@ -211,8 +211,8 @@ class Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Trigger WhenInactive(T&& command, bool interruptible = true) {
|
||||
CommandScheduler::GetInstance().AddButton(
|
||||
[pressedLast = Get(), *this,
|
||||
@@ -258,8 +258,8 @@ class Trigger {
|
||||
* @param interruptible Whether the command should be interruptible.
|
||||
* @return The trigger, for chained calls.
|
||||
*/
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of<
|
||||
Command, std::remove_reference_t<T>>::value>>
|
||||
template <class T, typename = std::enable_if_t<std::is_base_of_v<
|
||||
Command, std::remove_reference_t<T>>>>
|
||||
Trigger ToggleWhenActive(T&& command, bool interruptible = true) {
|
||||
CommandScheduler::GetInstance().AddButton(
|
||||
[pressedLast = Get(), *this,
|
||||
|
||||
@@ -22,7 +22,7 @@ struct vec_type_helper {
|
||||
|
||||
template <typename... Args>
|
||||
struct vec_type_helper<void, Args...> {
|
||||
using type = typename std::common_type<Args...>::type;
|
||||
using type = typename std::common_type_t<Args...>;
|
||||
};
|
||||
|
||||
template <typename T, typename... Args>
|
||||
@@ -33,14 +33,12 @@ struct all_constructible_and_convertible : std::true_type {};
|
||||
|
||||
template <typename T, typename First, typename... Rest>
|
||||
struct all_constructible_and_convertible<T, First, Rest...>
|
||||
: std::conditional<std::is_constructible<T, First>::value &&
|
||||
std::is_convertible<First, T>::value,
|
||||
all_constructible_and_convertible<T, Rest...>,
|
||||
std::false_type>::type {};
|
||||
: std::conditional_t<
|
||||
std::is_constructible_v<T, First> && std::is_convertible_v<First, T>,
|
||||
all_constructible_and_convertible<T, Rest...>, std::false_type> {};
|
||||
|
||||
template <typename T, typename... Args,
|
||||
typename std::enable_if<!std::is_trivially_copyable<T>::value,
|
||||
int>::type = 0>
|
||||
typename std::enable_if_t<!std::is_trivially_copyable_v<T>, int> = 0>
|
||||
std::vector<T> make_vector_impl(Args&&... args) {
|
||||
std::vector<T> vec;
|
||||
vec.reserve(sizeof...(Args));
|
||||
@@ -50,19 +48,18 @@ std::vector<T> make_vector_impl(Args&&... args) {
|
||||
}
|
||||
|
||||
template <typename T, typename... Args,
|
||||
typename std::enable_if<std::is_trivially_copyable<T>::value,
|
||||
int>::type = 0>
|
||||
typename std::enable_if_t<std::is_trivially_copyable_v<T>, int> = 0>
|
||||
std::vector<T> make_vector_impl(Args&&... args) {
|
||||
return std::vector<T>{std::forward<Args>(args)...};
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T = void, typename... Args,
|
||||
typename V = detail::vec_type_helper_t<T, Args...>,
|
||||
typename std::enable_if<
|
||||
detail::all_constructible_and_convertible<V, Args...>::value,
|
||||
int>::type = 0>
|
||||
template <
|
||||
typename T = void, typename... Args,
|
||||
typename V = detail::vec_type_helper_t<T, Args...>,
|
||||
typename std::enable_if_t<
|
||||
detail::all_constructible_and_convertible<V, Args...>::value, int> = 0>
|
||||
std::vector<V> make_vector(Args&&... args) {
|
||||
return detail::make_vector_impl<V>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user