Date
2015-05-05.21:08:43
Message id
7360

Content

Proposed resolution:

This wording is relative to N4296.

  1. Apply the following changes to [map.modifiers] p3+p4:

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

    -?- Requires: value_type shall be EmplaceConstructible into map from piecewise_construct, forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).

    -3- Effects: If the key k already exists in the map, there is no effect. Otherwise, inserts an element into the map. In the first and third forms, the element is constructed from the arguments as value_type(k, std::forward<Args>(args)...). In the second and fourth forms, the element is constructed from the arguments as value_type(std::move(k), std::forward<Args>(args)...). In the first two overloads, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the element of the map whose key is equivalent to k If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -4- Complexity: The same as emplace and emplace_hint, respectively.

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

    -?- Requires: value_type shall be EmplaceConstructible into map from piecewise_construct, forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).

    -?- Effects: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -?- Complexity: The same as emplace and emplace_hint, respectively.

  2. Apply the following changes to [map.modifiers] p5+p6:

    template <class M> pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
    template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
    

    -?- Requires: is_assignable<mapped_type&, M&&>::value shall be true. value_type shall be EmplaceConstructible into map from k, forward<M>(obj).

    -5- Effects: If the key k does not exist in the map, inserts an element into the map. In the first and third forms, the element is constructed from the arguments as value_type(k, std::forward<Args>(args)...). In the second and fourth forms, the element is constructed from the arguments as value_type(std::move(k), std::forward<Args>(args)...). If the key already exists, std::forward<M>(obj) is assigned to the mapped_type corresponding to the key. In the first two overloads, the bool component of the returned value is true if and only if the insertion took place. The returned iterator points to the element that was inserted or updated If the map already contains an element e whose key is equivalent to k, assigns forward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with k, forward<M>(obj).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -6- Complexity: The same as emplace and emplace_hint, respectively.

    template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
    

    -?- Requires: is_assignable<mapped_type&, M&&>::value shall be true. value_type shall be EmplaceConstructible into map from move(k), forward<M>(obj).

    -?- Effects: If the map already contains an element e whose key is equivalent to k, assigns forward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with move(k), forward<M>(obj).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -?- Complexity: The same as emplace and emplace_hint, respectively.

  3. Apply the following changes to [unord.map.modifiers] p5+p6:

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

    -?- Requires: value_type shall be EmplaceConstructible into unordered_map from piecewise_construct, forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).

    -5- Effects: If the key k already exists in the map, there is no effect. Otherwise, inserts an element into the map. In the first and third forms, the element is constructed from the arguments as value_type(k, std::forward<Args>(args)...). In the second and fourth forms, the element is constructed from the arguments as value_type(std::move(k), std::forward<Args>(args)...). In the first two overloads, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the element of the map whose key is equivalent to k If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -6- Complexity: The same as emplace and emplace_hint, respectively.

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

    -?- Requires: value_type shall be EmplaceConstructible into unordered_map from piecewise_construct, forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).

    -?- Effects: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -?- Complexity: The same as emplace and emplace_hint, respectively.

  4. Apply the following changes to [unord.map.modifiers] p7+p8:

    template <class M> pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
    template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
    

    -?- Requires: is_assignable<mapped_type&, M&&>::value shall be true. value_type shall be EmplaceConstructible into unordered_map from k, forward<M>(obj).

    -7- Effects: If the key k does not exist in the map, inserts an element into the map. In the first and third forms, the element is constructed from the arguments as value_type(k, std::forward<Args>(args)...). In the second and fourth forms, the element is constructed from the arguments as value_type(std::move(k), std::forward<Args>(args)...). If the key already exists, std::forward<M>(obj) is assigned to the mapped_type corresponding to the key. In the first two overloads, the bool component of the returned value is true if and only if the insertion took place. The returned iterator points to the element that was inserted or updated If the map already contains an element e whose key is equivalent to k, assigns forward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with k, forward<M>(obj).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -8- Complexity: The same as emplace and emplace_hint, respectively.

    template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
    template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
    

    -?- Requires: is_assignable<mapped_type&, M&&>::value shall be true. value_type shall be EmplaceConstructible into unordered_map from move(k), forward<M>(obj).

    -?- Effects: If the map already contains an element e whose key is equivalent to k, assigns forward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with move(k), forward<M>(obj).

    -?- Returns: In the first overload, the bool component of the returned pair is true if and only if the insertion took place. The returned iterator points to the map element whose key is equivalent to k.

    -?- Complexity: The same as emplace and emplace_hint, respectively.