summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qmap.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-06-05 12:39:58 +0200
committerLars Knoll <lars.knoll@qt.io>2020-07-08 14:13:55 +0200
commit16bc995fd1eba4f7485226f319e7736ca19040bc (patch)
tree75107f4854f97a4f0a5c340ab872d9a6a8a2d89c /src/corelib/tools/qmap.h
parentb038575a8995378b07e7c82cedc219c1ae40b167 (diff)
Add type traits to safely determine the existence of comparison operators
Containers often define an operator==() or operator<() which is very useful for generic code. But those operators can usually not be instantiated if the template argument doesn't implement the operator. This sometimes leads to the compiler trying all possible template expansions and implicit conversions for the type, giving extremely long error messages. The traits support can be used to safely constrain those operators. Being able to safely detect this will also allow us to fold the comparison support that is currently a large cludge for user types directly into QMetaType. Change-Id: Ib84afb5348c3eb0be5161d6ba9d5fe237709c65f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qmap.h')
-rw-r--r--src/corelib/tools/qmap.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 848ba5c4d4..a44f0088d3 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -567,6 +567,7 @@ public:
// STL compatibility
typedef Key key_type;
typedef T mapped_type;
+ typedef T value_type;
typedef qptrdiff difference_type;
typedef qsizetype size_type;
inline bool empty() const { return isEmpty(); }