aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorPaolo Carlini <paolo@gcc.gnu.org>2010-07-27 17:27:06 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-07-27 17:27:06 +0000
commitf67a9881a86bcdeb67fa52c0a8eb45ce9d4134d4 (patch)
treefe5f2e2bd09e714c8ed3e945800795e79446e5c6 /libstdc++-v3/include
parent9f39bd531612c767cbcf0148b3baa95a9122453e (diff)
downloadgcc-f67a9881a86bcdeb67fa52c0a8eb45ce9d4134d4.zip
gcc-f67a9881a86bcdeb67fa52c0a8eb45ce9d4134d4.tar.gz
gcc-f67a9881a86bcdeb67fa52c0a8eb45ce9d4134d4.tar.bz2
[multiple changes]
2010-07-27 Paolo Carlini <paolo.carlini@oracle.com> * include/ext/vstring_util.h: Include bits/range_access.h. * testsuite/ext/vstring/range_access.cc: New test. 2010-07-27 Ed Smith-Rowland <3dw4rd@verizon.net> * include/bits/range_access.h: New. * include/Makefile.in: Add bits/range_access.h. * include/Makefile.am: Regenerate. * include/std/array: Include bits/range_access.h. * include/std/deque: Ditto. * include/std/forward_list: Ditto. * include/std/iterator: Ditto. * include/std/list: Ditto. * include/std/map: Ditto. * include/std/regex: Ditto. * include/std/set: Ditto. * include/std/string: Ditto. * include/std/unordered_map: Ditto. * include/std/unordered_set: Ditto. * include/std/vector: Ditto. * include/std/valarray: Add begin() and end(). * libsupc++/initializer_list: Ditto. * include/tr1_impl/utility: Add begin() and end(). * include/std/tuple: Ditto. * testsuite/24_iterators/headers/iterator/range_access.cc: New test. * testsuite/24_iterators/range_access.cc: Ditto. * testsuite/28_regex/range_access.cc: Ditto. * testsuite/18_support/initializer_list/range_access.cc: Ditto. * testsuite/21_strings/basic_string/range_access.cc: Ditto. * testsuite/26_numerics/valarray/range_access.cc: Ditto. * testsuite/23_containers/unordered_map/range_access.cc: Ditto. * testsuite/23_containers/multimap/range_access.cc: Ditto. * testsuite/23_containers/set/range_access.cc: Ditto. * testsuite/23_containers/unordered_multimap/range_access.cc: Ditto. * testsuite/23_containers/forward_list/range_access.cc: Ditto. * testsuite/23_containers/unordered_set/range_access.cc: Ditto. * testsuite/23_containers/vector/range_access.cc: Ditto. * testsuite/23_containers/deque/range_access.cc: Ditto. * testsuite/23_containers/multiset/range_access.cc: Ditto. * testsuite/23_containers/list/range_access.cc: Ditto. * testsuite/23_containers/unordered_multiset/range_access.cc: Ditto. * testsuite/23_containers/map/range_access.cc: Ditto. * testsuite/23_containers/array/range_access.cc: Ditto. * testsuite/20_util/tuple/range_access.cc: Ditto. * testsuite/20_util/pair/range_access.cc: Ditto. From-SVN: r162578
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/Makefile.am1
-rw-r--r--libstdc++-v3/include/Makefile.in1
-rw-r--r--libstdc++-v3/include/bits/range_access.h102
-rw-r--r--libstdc++-v3/include/ext/vstring_util.h4
-rw-r--r--libstdc++-v3/include/std/array1
-rw-r--r--libstdc++-v3/include/std/deque1
-rw-r--r--libstdc++-v3/include/std/forward_list1
-rw-r--r--libstdc++-v3/include/std/iterator1
-rw-r--r--libstdc++-v3/include/std/list1
-rw-r--r--libstdc++-v3/include/std/map1
-rw-r--r--libstdc++-v3/include/std/regex1
-rw-r--r--libstdc++-v3/include/std/set1
-rw-r--r--libstdc++-v3/include/std/string1
-rw-r--r--libstdc++-v3/include/std/tuple18
-rw-r--r--libstdc++-v3/include/std/unordered_map1
-rw-r--r--libstdc++-v3/include/std/unordered_set1
-rw-r--r--libstdc++-v3/include/std/valarray42
-rw-r--r--libstdc++-v3/include/std/vector1
-rw-r--r--libstdc++-v3/include/tr1_impl/utility20
19 files changed, 199 insertions, 1 deletions
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 6c0230a..6a371a4 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -121,6 +121,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
+ ${bits_srcdir}/range_access.h \
${bits_srcdir}/regex.h \
${bits_srcdir}/regex_compiler.h \
${bits_srcdir}/regex_constants.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 430f85a..1aa641a 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -363,6 +363,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
+ ${bits_srcdir}/range_access.h \
${bits_srcdir}/regex.h \
${bits_srcdir}/regex_compiler.h \
${bits_srcdir}/regex_constants.h \
diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
new file mode 100644
index 0000000..e9bf67e
--- /dev/null
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -0,0 +1,102 @@
+// <range_access.h> -*- C++ -*-
+
+// Copyright (C) 2010 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 bits/range_access.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef _GLIBCXX_RANGE_ACCESS_H
+#define _GLIBCXX_RANGE_ACCESS_H 1
+
+#pragma GCC system_header
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the container.
+ * @param cont Container.
+ */
+ template<class _Container>
+ inline auto
+ begin(_Container& __cont) -> decltype(__cont.begin())
+ { return __cont.begin(); }
+
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the const container.
+ * @param cont Container.
+ */
+ template<class _Container>
+ inline auto
+ begin(const _Container& __cont) -> decltype(__cont.begin())
+ { return __cont.begin(); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the container.
+ * @param cont Container.
+ */
+ template<class _Container>
+ inline auto
+ end(_Container& __cont) -> decltype(__cont.end())
+ { return __cont.end(); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the const container.
+ * @param cont Container.
+ */
+ template<class _Container>
+ inline auto
+ end(const _Container& __cont) -> decltype(__cont.end())
+ { return __cont.end(); }
+
+ /**
+ * @brief Return an iterator pointing to the first element of the array.
+ * @param arr Array.
+ */
+ template<class _Tp, size_t _Nm>
+ inline _Tp*
+ begin(_Tp (&__arr)[_Nm])
+ { return __arr; }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element
+ * of the array.
+ * @param arr Array.
+ */
+ template<class _Tp, size_t _Nm>
+ inline _Tp*
+ end(_Tp (&__arr)[_Nm])
+ { return __arr + _Nm; }
+
+_GLIBCXX_END_NAMESPACE
+
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
+#endif // _GLIBCXX_RANGE_ACCESS_H
diff --git a/libstdc++-v3/include/ext/vstring_util.h b/libstdc++-v3/include/ext/vstring_util.h
index 4042f70..6779f4d 100644
--- a/libstdc++-v3/include/ext/vstring_util.h
+++ b/libstdc++-v3/include/ext/vstring_util.h
@@ -1,6 +1,7 @@
// Versatile string utility -*- C++ -*-
-// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+// 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
@@ -42,6 +43,7 @@
#include <bits/stl_iterator.h>
#include <ext/numeric_traits.h>
#include <bits/move.h>
+#include <bits/range_access.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index d374c88..26e762d 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -40,6 +40,7 @@
#endif
#include <bits/stl_algobase.h>
+#include <bits/range_access.h>
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# include <tr1_impl/array>
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index f8a55f7..b7f4b0a 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -63,6 +63,7 @@
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_deque.h>
+#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/deque.tcc>
diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list
index 16fdcc2..8b11db7 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -36,6 +36,7 @@
#else
#include <bits/forward_list.h>
+#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/forward_list.tcc>
diff --git a/libstdc++-v3/include/std/iterator b/libstdc++-v3/include/std/iterator
index 5395106..90152b7 100644
--- a/libstdc++-v3/include/std/iterator
+++ b/libstdc++-v3/include/std/iterator
@@ -65,5 +65,6 @@
#include <istream>
#include <bits/stream_iterator.h>
#include <bits/streambuf_iterator.h>
+#include <bits/range_access.h>
#endif /* _GLIBCXX_ITERATOR */
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index fcf164b..566bd89 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -61,6 +61,7 @@
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_list.h>
+#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/list.tcc>
diff --git a/libstdc++-v3/include/std/map b/libstdc++-v3/include/std/map
index 25f86df..0ff8bdd 100644
--- a/libstdc++-v3/include/std/map
+++ b/libstdc++-v3/include/std/map
@@ -60,6 +60,7 @@
#include <bits/stl_tree.h>
#include <bits/stl_map.h>
#include <bits/stl_multimap.h>
+#include <bits/range_access.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/map>
diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
index 95ad423..eabb843 100644
--- a/libstdc++-v3/include/std/regex
+++ b/libstdc++-v3/include/std/regex
@@ -52,6 +52,7 @@
#include <utility>
#include <vector>
+#include <bits/range_access.h>
#include <bits/regex_constants.h>
#include <bits/regex_error.h>
#include <bits/regex_cursor.h>
diff --git a/libstdc++-v3/include/std/set b/libstdc++-v3/include/std/set
index 0b7805c..47d0c97 100644
--- a/libstdc++-v3/include/std/set
+++ b/libstdc++-v3/include/std/set
@@ -60,6 +60,7 @@
#include <bits/stl_tree.h>
#include <bits/stl_set.h>
#include <bits/stl_multiset.h>
+#include <bits/range_access.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/set>
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index 8c5949f..439557f 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -51,6 +51,7 @@
#include <ext/numeric_traits.h>
#include <bits/stl_algobase.h>
#include <bits/basic_string.h>
+#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/basic_string.tcc>
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 8b2252e..d243251 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -697,6 +697,24 @@ namespace std
const _Swallow_assign ignore{};
/**
+ * @brief Return the first of a tuple containing two input iterators.
+ * @param tpl Tuple.
+ */
+ template<class _InputIterator>
+ inline _InputIterator
+ begin(const tuple<_InputIterator, _InputIterator>& __tpl)
+ { return get<0>(__tpl); }
+
+ /**
+ * @brief Return the second of a tuple containing two input iterators.
+ * @param tpl Tuple.
+ */
+ template<class _InputIterator>
+ inline _InputIterator
+ end(const tuple<_InputIterator, _InputIterator>& __tpl)
+ { return get<1>(__tpl); }
+
+ /**
* Stores a tuple of indices. Used by bind() to extract the elements
* in a tuple.
*/
diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map
index 8b664e8..e77a297 100644
--- a/libstdc++-v3/include/std/unordered_map
+++ b/libstdc++-v3/include/std/unordered_map
@@ -44,6 +44,7 @@
#include <bits/functional_hash.h>
#include <bits/hashtable.h>
#include <bits/unordered_map.h>
+#include <bits/range_access.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/unordered_map>
diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set
index edbf8f1..739e0a4 100644
--- a/libstdc++-v3/include/std/unordered_set
+++ b/libstdc++-v3/include/std/unordered_set
@@ -44,6 +44,7 @@
#include <bits/functional_hash.h>
#include <bits/hashtable.h>
#include <bits/unordered_set.h>
+#include <bits/range_access.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/unordered_set>
diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray
index f15ac92..d67eae2 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -1107,6 +1107,48 @@ _DEFINE_BINARY_OPERATOR(>=, __greater_equal)
#undef _DEFINE_BINARY_OPERATOR
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the valarray.
+ * @param va valarray.
+ */
+ template<class _Tp>
+ inline _Tp*
+ begin(valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]); }
+
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the const valarray.
+ * @param va valarray.
+ */
+ template<class _Tp>
+ inline const _Tp*
+ begin(const valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the valarray.
+ * @param va valarray.
+ */
+ template<class _Tp>
+ inline _Tp*
+ end(valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]) + __va.size(); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the const valarray.
+ * @param va valarray.
+ */
+ template<class _Tp>
+ inline const _Tp*
+ end(const valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]) + __va.size(); }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
// @} group numeric_arrays
_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector
index 41ecdde..ca44aac 100644
--- a/libstdc++-v3/include/std/vector
+++ b/libstdc++-v3/include/std/vector
@@ -64,6 +64,7 @@
#include <bits/stl_uninitialized.h>
#include <bits/stl_vector.h>
#include <bits/stl_bvector.h>
+#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/vector.tcc>
diff --git a/libstdc++-v3/include/tr1_impl/utility b/libstdc++-v3/include/tr1_impl/utility
index a31c4da..c3b3527 100644
--- a/libstdc++-v3/include/tr1_impl/utility
+++ b/libstdc++-v3/include/tr1_impl/utility
@@ -115,6 +115,26 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
get(const std::pair<_Tp1, _Tp2>& __in)
{ return __pair_get<_Int>::__const_get(__in); }
+#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
+ /**
+ * @brief Return the first of a pair containing two input iterators.
+ * @param p Pair.
+ */
+ template<class _InputIterator>
+ inline _InputIterator
+ begin(const std::pair<_InputIterator, _InputIterator>& __p)
+ { return __p.first; }
+
+ /**
+ * @brief Return the second of a pair containing two input iterators.
+ * @param p Pair.
+ */
+ template<class _InputIterator>
+ inline _InputIterator
+ end(const std::pair<_InputIterator, _InputIterator>& __p)
+ { return __p.second; }
+#endif
+
_GLIBCXX_END_NAMESPACE_TR1
}