summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/testsuite/25_algorithms/fill/2.cc
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-25 09:25:57 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-25 09:25:57 +0000
commit8ba26e53dd4b6ba9d986e4f0d48e30c7002f0f28 (patch)
tree1a8e35aa04613745272fa79f855dad4081915c11 /libstdc++-v3/testsuite/25_algorithms/fill/2.cc
parent521f4757cffb9e7283e60e03e95cf858b793c8da (diff)
downloadppe42-gcc-8ba26e53dd4b6ba9d986e4f0d48e30c7002f0f28.tar.gz
ppe42-gcc-8ba26e53dd4b6ba9d986e4f0d48e30c7002f0f28.zip
2004-06-25 Dan Nicolaescu <dann@ics.uci.edu>
Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algobase.h (__fill, __fill_n): New helpers for fill and fill_n, respectively: when copying is cheap, use a temporary to avoid a memory read in each iteration. 2004-06-25 Paolo Carlini <pcarlini@suse.de> * testsuite/25_algorithms/fill/1.cc: New. * testsuite/25_algorithms/fill/2.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83645 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms/fill/2.cc')
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/fill/2.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/2.cc b/libstdc++-v3/testsuite/25_algorithms/fill/2.cc
new file mode 100644
index 00000000000..4f0437e80fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/fill/2.cc
@@ -0,0 +1,69 @@
+// 2004-06-25 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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 2, 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.5 [lib.alg.fill] Fill
+
+#include <list>
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+class num
+{
+ int stored;
+
+public:
+ num(int init = 0)
+ : stored(init)
+ { }
+
+ operator int() const
+ { return stored; }
+};
+
+// fill_n
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const int val = 3;
+
+ const int V[] = { val, val, val, val, val, val, val, val, val };
+ const list<int>::size_type N = sizeof(V) / sizeof(int);
+
+ list<int> coll(N);
+ fill_n(coll.begin(), coll.size(), val);
+ VERIFY( equal(coll.begin(), coll.end(), V) );
+
+ list<num> coll2(N);
+ fill_n(coll2.begin(), coll2.size(), val);
+ VERIFY( equal(coll2.begin(), coll2.end(), V) );
+}
+
+#if !__GXX_WEAK__ && _MT_ALLOCATOR_H
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template class __gnu_cxx::__mt_alloc<std::_List_node<int> >;
+#endif
+
+int main()
+{
+ test01();
+ return 0;
+}
OpenPOWER on IntegriCloud