From dc0f3120227be8832f9d35fe5fe8c3ae4e69524a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?= Date: Sat, 27 Jan 2024 18:13:01 +0100 Subject: [PATCH] New issue from Jiang An: "Inconsistent preconditions for transparent insertion of std::flat_map/std::flat_set" --- xml/issue4048.xml | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 xml/issue4048.xml diff --git a/xml/issue4048.xml b/xml/issue4048.xml new file mode 100644 index 0000000000..79bc4eac70 --- /dev/null +++ b/xml/issue4048.xml @@ -0,0 +1,74 @@ + + + + +Inconsistent preconditions for transparent insertion of <tt>std::flat_map/std::flat_set</tt> +
+Jiang An +26 Jan 2024 +99 + + +

+The preconditions for transparent insertion of associative containers (/13, +/29, and /3) detect the results of equal_range, +while those for std::flat_set and std::flat_map (/2 and +/20) currently detect the results of find, which is inconsistent. +

+During implementing std::flat_set in MSVC STL, it was reported +(microsoft/STL#4105) that the current preconditions +for std::flat_set::insert can lead to inconsistent results. Tim Song told that the current preconditions +were copied from old revisions of . So, presumably we should change these preconditions for +flat container adaptors to consistently use equal_range. +

+
+ + +

+This wording is relative to . +

+ +
    +
  1. Modify as indicated:

    + +
    +
    +template<class K, class... Args>
    +  pair<iterator, bool> try_emplace(K&& k, Args&&... args);
    +template<class K, class... Args>
    +  iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
    +
    +
    +

    +[…] +

    +-20- Preconditions: The conversion from k into key_type constructs an +object u, for which find(k) == find(u)equal_range(k) == equal_range(u) +is true. +

    +
    +
    +
  2. + +
  3. Modify as indicated:

    + +
    +
    +template<class K> pair<iterator, bool> insert(K&& x);
    +template<class K> iterator insert(const_iterator hint, K&& x);
    +
    +
    +

    +[…] +

    +-2- Preconditions: The conversion from x into value_type constructs an +object u, for which find(x) == find(u)equal_range(x) == equal_range(u) +is true. +

    +
    +
    +
  4. +
+
+ +