mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11: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:
18
wpiutil/src/main/native/include/wpi/DecayedDerivedFrom.h
Normal file
18
wpiutil/src/main/native/include/wpi/DecayedDerivedFrom.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "wpi/concepts.h"
|
||||
|
||||
namespace wpi {
|
||||
|
||||
template <class Derived, class Base>
|
||||
concept DecayedDerivedFrom =
|
||||
std::derived_from<std::decay_t<Derived>, std::decay_t<Base>> &&
|
||||
std::convertible_to<std::decay_t<Derived>*, std::decay_t<Base>*>;
|
||||
|
||||
} // namespace wpi
|
||||
Reference in New Issue
Block a user