public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3 PATCH] Implement N4279, Improved insertion interface for unique-key maps.
@ 2015-07-20 23:09 Ville Voutilainen
  2015-08-07  8:36 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Ville Voutilainen @ 2015-07-20 23:09 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 787 bytes --]

Tested on Linux-PPC64.

2015-07-21  Ville Voutilainen  <ville.voutilainen@gmail.com>
    Implement N4279, Improved insertion interface for unique-key maps.
    * include/bits/stl_map.h (try_emplace, insert_or_assign): New.
    * include/bits/stl_tree.h (_M_get_insert_unique_pos,
    _M_get_insert_equal_pos, _M_get_insert_hint_unique_pos,
    _M_get_insert_hint_equal_pos): Make public.
    * include/bits/unordered_map.h (try_emplace, insert_or_assign): New.
    * testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
    Likewise.
    * testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise.
    * testsuite/23_containers/unordered_map/modifiers/insert_or_assign.cc:
    Likewise.
    * testsuite/23_containers/unordered_map/modifiers/try_emplace.cc:
    Likewise.

[-- Attachment #2: improved-interface.diff.gz --]
[-- Type: application/x-gzip, Size: 4399 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v3 PATCH] Implement N4279, Improved insertion interface for unique-key maps.
  2015-07-20 23:09 [v3 PATCH] Implement N4279, Improved insertion interface for unique-key maps Ville Voutilainen
@ 2015-08-07  8:36 ` Jonathan Wakely
  2015-08-08 10:38   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2015-08-07  8:36 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: libstdc++, gcc-patches

On 21/07/15 00:49 +0300, Ville Voutilainen wrote:
>Tested on Linux-PPC64.
>
>2015-07-21  Ville Voutilainen  <ville.voutilainen@gmail.com>
>    Implement N4279, Improved insertion interface for unique-key maps.
>    * include/bits/stl_map.h (try_emplace, insert_or_assign): New.
>    * include/bits/stl_tree.h (_M_get_insert_unique_pos,
>    _M_get_insert_equal_pos, _M_get_insert_hint_unique_pos,
>    _M_get_insert_hint_equal_pos): Make public.
>    * include/bits/unordered_map.h (try_emplace, insert_or_assign): New.
>    * testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
>    Likewise.
>    * testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise.
>    * testsuite/23_containers/unordered_map/modifiers/insert_or_assign.cc:
>    Likewise.
>    * testsuite/23_containers/unordered_map/modifiers/try_emplace.cc:
>    Likewise.


+      template <typename... _Args>
+      pair<iterator, bool>

Indent everything after 'template<...>' please.

+      try_emplace(const key_type& __k, _Args&&... __args)
+      {
+	iterator __i = lower_bound(__k);
+	if (__i == end() || key_comp()(__k, (*__i).first))
+          {
+	    __i = emplace_hint(__i, std::piecewise_construct,
+                    std::forward_as_tuple(__k),
+                    std::forward_as_tuple(std::forward<_Args>(__args)...));
+            return {__i, true};
+          }
+        return {__i, false};
+      }

Add a blank line between functions please.

+      // move-capable overload
+      template <typename... _Args>
+      pair<iterator, bool>
+      try_emplace(key_type&& __k, _Args&&... __args)



+      template <typename _M>

_M isn't documented as a BADNAME but single character names like that make me
nervous, would _Obj or _Up be OK?

+      pair<iterator, bool>
+      insert_or_assign(const key_type& __k, _M&& __obj)
+      {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v3 PATCH] Implement N4279, Improved insertion interface for unique-key maps.
  2015-08-07  8:36 ` Jonathan Wakely
@ 2015-08-08 10:38   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2015-08-08 10:38 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: libstdc++, gcc-patches

On 07/08/15 09:36 +0100, Jonathan Wakely wrote:
>On 21/07/15 00:49 +0300, Ville Voutilainen wrote:
>+      template <typename... _Args>
>+      pair<iterator, bool>
>
>Indent everything after 'template<...>' please.
>
>+      try_emplace(const key_type& __k, _Args&&... __args)
>+      {
>+	iterator __i = lower_bound(__k);
>+	if (__i == end() || key_comp()(__k, (*__i).first))
>+          {
>+	    __i = emplace_hint(__i, std::piecewise_construct,
>+                    std::forward_as_tuple(__k),
>+                    std::forward_as_tuple(std::forward<_Args>(__args)...));
>+            return {__i, true};
>+          }
>+        return {__i, false};
>+      }
>
>Add a blank line between functions please.
>
>+      // move-capable overload
>+      template <typename... _Args>
>+      pair<iterator, bool>
>+      try_emplace(key_type&& __k, _Args&&... __args)
>
>
>
>+      template <typename _M>
>
>_M isn't documented as a BADNAME but single character names like that make me
>nervous, would _Obj or _Up be OK?
>
>+      pair<iterator, bool>
>+      insert_or_assign(const key_type& __k, _M&& __obj)
>+      {
>

P.S. I should have said it's OK for trunk with those changes.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-08 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 23:09 [v3 PATCH] Implement N4279, Improved insertion interface for unique-key maps Ville Voutilainen
2015-08-07  8:36 ` Jonathan Wakely
2015-08-08 10:38   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).