From 1162b4bfc9149ef50bb39b15ecba5ac6ba158290 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 10 Sep 2020 18:23:23 +0200 Subject: Add a QMetaAssociation This requires refactoring of QMetaSequence, as they share a lot of common functionality. QMetaAssociation provides a low level interface to an associative container. Task-number: QTBUG-81716 Change-Id: I273e00abd82f1549ba8803c323d82aa3a2d12ded Reviewed-by: Lars Knoll --- src/corelib/global/qcontainerinfo.h | 122 +++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 8 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qcontainerinfo.h b/src/corelib/global/qcontainerinfo.h index c6ee9328ec..e0025fcef0 100644 --- a/src/corelib/global/qcontainerinfo.h +++ b/src/corelib/global/qcontainerinfo.h @@ -51,6 +51,12 @@ namespace QContainerTraits template using value_type = typename C::value_type; +template +using key_type = typename C::key_type; + +template +using mapped_type = typename C::mapped_type; + template using iterator = typename C::iterator; @@ -61,6 +67,21 @@ using const_iterator = typename C::const_iterator; QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-const-variable") +template +constexpr bool has_value_type_v = false; +template +constexpr bool has_value_type_v>> = true; + +template +constexpr bool has_key_type_v = false; +template +constexpr bool has_key_type_v>> = true; + +template +constexpr bool has_mapped_type_v = false; +template +constexpr bool has_mapped_type_v>> = true; + template constexpr bool has_size_v = false; template @@ -72,9 +93,14 @@ template constexpr bool has_clear_v> = true; template -constexpr bool has_at_v = false; +constexpr bool has_at_index_v = false; +template +constexpr bool has_at_index_v> = true; + +template +constexpr bool has_at_key_v = false; template -constexpr bool has_at_v> = true; +constexpr bool has_at_key_v()))>> = true; template constexpr bool can_get_at_index_v = false; @@ -122,19 +148,19 @@ template constexpr bool has_const_iterator_v>> = true; template -constexpr bool can_get_at_iterator_v = false; +constexpr bool can_set_value_at_iterator_v = false; template -constexpr bool can_get_at_iterator_v(decltype(*C().begin()))>> = true; +constexpr bool can_set_value_at_iterator_v())>> = true; template -constexpr bool can_set_at_iterator_v = false; +constexpr bool can_set_mapped_at_iterator_v = false; template -constexpr bool can_set_at_iterator_v())>> = true; +constexpr bool can_set_mapped_at_iterator_v())>> = true; template -constexpr bool can_insert_at_iterator_v = false; +constexpr bool can_insert_value_at_iterator_v = false; template -constexpr bool can_insert_at_iterator_v()))>> = true; +constexpr bool can_insert_value_at_iterator_v()))>> = true; template constexpr bool can_erase_at_iterator_v = false; @@ -146,6 +172,86 @@ constexpr bool can_erase_range_at_iterator_v = false; template constexpr bool can_erase_range_at_iterator_v> = true; +template +constexpr bool can_get_at_key_v = false; +template +constexpr bool can_get_at_key_v(decltype(C()[key_type()]))>> = true; + +template +constexpr bool can_set_at_key_v = false; +template +constexpr bool can_set_at_key_v()] = mapped_type())>> = true; + +template +constexpr bool can_erase_at_key_v = false; +template +constexpr bool can_erase_at_key_v()))>> = true; + +template +constexpr bool can_remove_at_key_v = false; +template +constexpr bool can_remove_at_key_v()))>> = true; + +template +constexpr bool can_insert_key_v = false; +template +constexpr bool can_insert_key_v()))>> = true; + +template +constexpr bool can_insert_pair_v = false; +template +constexpr bool can_insert_pair_v(), mapped_type()}))>> = true; + +template +constexpr bool can_insert_key_mapped_v = false; +template +constexpr bool can_insert_key_mapped_v(), mapped_type()))>> = true; + +template +constexpr bool has_contains_v = false; +template +constexpr bool has_contains_v())))>> = true; + +template +constexpr bool has_find_v = false; +template +constexpr bool has_find_v()))>> = true; + +template +constexpr bool iterator_dereferences_to_value_v = false; +template +constexpr bool iterator_dereferences_to_value_v(*C().begin()))>> = true; + +template +constexpr bool iterator_has_key_v = false; +template +constexpr bool iterator_has_key_v(C().begin().key()))>> = true; + +template +constexpr bool value_type_has_first_v = false; +template +constexpr bool value_type_has_first_v(value_type().first))>> = true; + +template +constexpr bool iterator_dereferences_to_key_v = false; +template +constexpr bool iterator_dereferences_to_key_v(*C().begin()))>> = true; + +template +constexpr bool iterator_has_value_v = false; +template +constexpr bool iterator_has_value_v(C().begin().value()))>> = true; + +template +constexpr bool value_type_has_second_v = false; +template +constexpr bool value_type_has_second_v(value_type().second))>> = true; + +template +constexpr bool iterator_dereferences_to_mapped_v = false; +template +constexpr bool iterator_dereferences_to_mapped_v(*C().begin()))>> = true; + QT_WARNING_POP } -- cgit v1.2.3