From 5507d9461b067f09c32558a2bd769d03eb5870e4 Mon Sep 17 00:00:00 2001 From: "Dr. Patrick Urbanke" Date: Sun, 7 Dec 2025 22:46:29 +0100 Subject: [PATCH] Replace enable_if with concepts --- include/sqlgen/ForeignKey.hpp | 15 ++++++--------- include/sqlgen/JSON.hpp | 16 ++++++++-------- include/sqlgen/PrimaryKey.hpp | 20 ++++++++------------ include/sqlgen/Unique.hpp | 15 ++++++--------- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/include/sqlgen/ForeignKey.hpp b/include/sqlgen/ForeignKey.hpp index 1e038af4..c2233c2f 100644 --- a/include/sqlgen/ForeignKey.hpp +++ b/include/sqlgen/ForeignKey.hpp @@ -47,14 +47,12 @@ struct ForeignKey { ForeignKey(const ForeignKey& _other) = default; - template , - bool>::type = true> + template + requires std::is_convertible_v ForeignKey(const U& _value) : value_(_value) {} - template , - bool>::type = true> + template + requires std::is_convertible_v ForeignKey(U&& _value) noexcept : value_(std::forward(_value)) {} ~ForeignKey() = default; @@ -78,9 +76,8 @@ struct ForeignKey { } /// Assigns the underlying object. - template , - bool>::type = true> + template + requires std::is_convertible_v auto& operator=(const U& _value) { value_ = _value; return *this; diff --git a/include/sqlgen/JSON.hpp b/include/sqlgen/JSON.hpp index d1c4f903..87bff466 100644 --- a/include/sqlgen/JSON.hpp +++ b/include/sqlgen/JSON.hpp @@ -27,16 +27,16 @@ class JSON { template JSON(JSON&& _other) : value_(_other.get()) {} - template , - bool>::type = true> + template + requires std::is_convertible_v JSON(const U& _value) : value_(_value) {} - template , - bool>::type = true> + template + requires std::is_convertible_v JSON(U&& _value) noexcept : value_(std::forward(_value)) {} - template , - bool>::type = true> + template + requires std::is_convertible_v JSON(const JSON& _other) : value_(_other.value()) {} ~JSON() = default; @@ -60,8 +60,8 @@ class JSON { } /// Assigns the underlying object. - template , - bool>::type = true> + template + requires std::is_convertible_v auto& operator=(const U& _value) { value_ = _value; return *this; diff --git a/include/sqlgen/PrimaryKey.hpp b/include/sqlgen/PrimaryKey.hpp index b5b5831a..875a1362 100644 --- a/include/sqlgen/PrimaryKey.hpp +++ b/include/sqlgen/PrimaryKey.hpp @@ -36,19 +36,16 @@ struct PrimaryKey { template PrimaryKey(PrimaryKey&& _other) : value_(_other.get()) {} - template , - bool>::type = true> + template + requires std::is_convertible_v PrimaryKey(const U& _value) : value_(_value) {} - template , - bool>::type = true> + template + requires std::is_convertible_v PrimaryKey(U&& _value) noexcept : value_(std::forward(_value)) {} - template , - bool>::type = true> + template + requires std::is_convertible_v PrimaryKey(const PrimaryKey& _other) : value_(_other.value()) {} ~PrimaryKey() = default; @@ -72,9 +69,8 @@ struct PrimaryKey { } /// Assigns the underlying object. - template , - bool>::type = true> + template + requires std::is_convertible_v auto& operator=(const U& _value) { value_ = _value; return *this; diff --git a/include/sqlgen/Unique.hpp b/include/sqlgen/Unique.hpp index 1a1b2055..96b4792c 100644 --- a/include/sqlgen/Unique.hpp +++ b/include/sqlgen/Unique.hpp @@ -25,14 +25,12 @@ struct Unique { Unique(const Unique& _other) = default; - template , - bool>::type = true> + template + requires std::is_convertible_v Unique(const U& _value) : value_(_value) {} - template , - bool>::type = true> + template + requires std::is_convertible_v Unique(U&& _value) noexcept : value_(std::forward(_value)) {} ~Unique() = default; @@ -56,9 +54,8 @@ struct Unique { } /// Assigns the underlying object. - template , - bool>::type = true> + template + requires std::is_convertible_v auto& operator=(const U& _value) { value_ = _value; return *this;