File: gi-avoid-incomplete-type-in-std%3A%3Ais_convertible.patch

package info (click to toggle)
cppgir 2.0%2Bgit20240928.c8bb1c6%2Breally2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,228 kB
  • sloc: cpp: 14,307; ansic: 339; makefile: 11; sh: 9
file content (41 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 13276585de2874d23c523b4539afa0d677bc5db6 Mon Sep 17 00:00:00 2001
From: Mark Nauwelaerts <mnauw@users.sourceforge.net>
Date: Wed, 20 Dec 2023 19:52:07 +0100
Subject: [PATCH] gi: avoid incomplete type in std::is_convertible

See issue #65
---
 gi/container.hpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/gi/container.hpp b/gi/container.hpp
index 78c14bc..2d53e42 100644
--- a/gi/container.hpp
+++ b/gi/container.hpp
@@ -1499,10 +1499,20 @@ public:
         std::true_type, std::false_type>::type;
 
     // check Cpp type compatibility
+    // this could be triggered on non-complete V, in which case
+    // std::is_convertible is undefined, so guard that approach
+    template<typename V, bool Complete = false>
+    struct is_acceptable_helper : public std::integral_constant<bool, false>
+    {};
+
     template<typename V>
-    using is_acceptable =
-        typename std::conditional<std::is_convertible<V, ValueCppType>::value,
-            std::true_type, std::false_type>::type;
+    struct is_acceptable_helper<V, true>
+        : public std::is_convertible<V, ValueCppType>
+    {};
+
+    template<typename V>
+    using is_acceptable = typename is_acceptable_helper<V,
+        traits::is_type_complete<V>::value>::type;
 
     // likewise, deal with const variations on e.g. char**
     // (as char* can be converted to const char*)
-- 
GitLab