This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [libstdc++] Add uniform container erasure.


On 30/04/15 07:33 -0400, Ed Smith-Rowland wrote:
This has been in me tree for a good while.

It is fairly simple and adds C++ experimental container erasure.

And make_array, which isn't in the working paper yet, so I'd prefer to
leave that part out for now.


Index: include/experimental/erase_if.tcc
===================================================================
--- include/experimental/erase_if.tcc	(revision 0)
+++ include/experimental/erase_if.tcc	(working copy)
@@ -0,0 +1,70 @@
+// <experimental/erase_if.tcc> -*- C++ -*-
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file experimental/erase_if.tcc
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{erase_if}

The Doxygen @headername command tells users which header they are
supposed to include, rather than this one. Since there is no
<erase_if> header that's wrong. I'd just omit the @headername.


+ */
+
+#ifndef _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC
+#define _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+namespace std
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+
+  namespace __detail
+  {
+    template<typename _Container, typename _Predicate>
+      void
+      __erase_nodes_if(_Container& __cont, _Predicate __pred)
+      {
+	for (auto __iter = __cont.begin(), __last = __cont.end();
+	     __iter != __last;)
+	{
+	  if (__pred(*__iter))
+	    __iter = __cont.erase(__iter);
+	  else
+	    ++__iter;
+	}
+      }
+  }

This file doesn't really seem like a .tcc to me, it isn't providing
definitions of templates declared elsewhere (specifically in an
erase_if.h header).

Maybe we want an experimental/bits/ directory for this sort of thing
(which I could also use for the filesystem headers I'm about to
commit) but in the meanwhile I think just experimental/erase_if.h is a
better name.


OK for trunk with those changes (remove make_array, rename erase_if.tcc)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]