summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qpropertyprivate.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index 8fe8cc7ff2..ddb09bb119 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -184,6 +184,12 @@ struct QPropertyProxyBindingData
namespace QtPrivate {
struct BindingEvaluationState;
+/* used in BindingFunctionVTable::createFor; on all other compilers, void would work, but on
+ MSVC this causes C2182 when compiling in C++20 mode. As we only need to provide some default
+ value which gets ignored, we introduce this dummy type.
+*/
+struct MSVCWorkAround {};
+
struct BindingFunctionVTable
{
using CallFn = bool(*)(QMetaType, QUntypedPropertyData *, void *);
@@ -194,7 +200,7 @@ struct BindingFunctionVTable
const MoveCtrFn moveConstruct;
const qsizetype size;
- template<typename Callable, typename PropertyType=void>
+ template<typename Callable, typename PropertyType=MSVCWorkAround>
static constexpr BindingFunctionVTable createFor()
{
static_assert (alignof(Callable) <= alignof(std::max_align_t), "Bindings do not support overaligned functors!");
@@ -205,7 +211,7 @@ struct BindingFunctionVTable
static_assert (std::is_invocable_r_v<bool, Callable, QMetaType, QUntypedPropertyData *> );
auto untypedEvaluationFunction = static_cast<Callable *>(f);
return std::invoke(*untypedEvaluationFunction, metaType, dataPtr);
- } else if constexpr (!std::is_same_v<PropertyType, void>) { // check for void to workaround MSVC issue
+ } else if constexpr (!std::is_same_v<PropertyType, MSVCWorkAround>) {
Q_UNUSED(metaType);
QPropertyData<PropertyType> *propertyPtr = static_cast<QPropertyData<PropertyType> *>(dataPtr);
// That is allowed by POSIX even if Callable is a function pointer
@@ -232,7 +238,7 @@ struct BindingFunctionVTable
}
};
-template<typename Callable, typename PropertyType=void>
+template<typename Callable, typename PropertyType=MSVCWorkAround>
inline constexpr BindingFunctionVTable bindingFunctionVTable = BindingFunctionVTable::createFor<Callable, PropertyType>();