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

@@ -8,11 +8,11 @@
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <networktables/NetworkTable.h>
#include <wpi/StringMap.h>
#include <wpi/concepts.h>
#include "frc/Errors.h"
@@ -62,9 +62,8 @@ class MechanismObject2d {
* assignments and call chaining.
* @throw if an object with the given name already exists.
*/
template <typename T, typename... Args,
typename =
std::enable_if_t<std::is_convertible_v<T*, MechanismObject2d*>>>
template <typename T, typename... Args>
requires std::convertible_to<T*, MechanismObject2d*>
T* Append(std::string_view name, Args&&... args) {
std::scoped_lock lock(m_mutex);
auto& obj = m_objects[name];