From ba39bb27305e4eb788f3538061a604e558714472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Patrick=20Urbanke=20=28=E5=8A=89=E8=87=AA=E6=88=90?= =?UTF-8?q?=29?= Date: Mon, 8 Dec 2025 00:13:11 +0100 Subject: [PATCH] Replace enable_if with concepts (#106) --- 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 1e038af..c2233c2 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 d1c4f90..87bff46 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 b5b5831..875a136 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 1a1b205..96b4792 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;