Commit f67a9881 by Paolo Carlini

[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
parent 9f39bd53
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.
2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* acinclude.m4 ([GLIBCXX_CHECK_STDIO_MACROS]): Remove.
......
......@@ -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 \
......
......@@ -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 \
......
// <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
// 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)
......
......@@ -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>
......
......@@ -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>
......
......@@ -36,6 +36,7 @@
#else
#include <bits/forward_list.h>
#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/forward_list.tcc>
......
......@@ -65,5 +65,6 @@
#include <istream>
#include <bits/stream_iterator.h>
#include <bits/streambuf_iterator.h>
#include <bits/range_access.h>
#endif /* _GLIBCXX_ITERATOR */
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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.
*/
......
......@@ -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>
......
......@@ -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>
......
......@@ -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
......
......@@ -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>
......
......@@ -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
}
......@@ -75,6 +75,26 @@ namespace std
const_iterator
end() const { return begin() + size(); }
};
/**
* @brief Return an iterator pointing to the first element of
* the initilizer_list.
* @param il Initializer list.
*/
template<class _Tp>
inline const _Tp*
begin(initializer_list<_Tp> __ils)
{ return __ils.begin(); }
/**
* @brief Return an iterator pointing to one past the last element
* of the initilizer_list.
* @param il Initializer list.
*/
template<class _Tp>
inline const _Tp*
end(initializer_list<_Tp> __ils)
{ return __ils.end(); }
}
#pragma GCC visibility pop
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 18.9.3 Initializer list range access [support.initlist.range]
#include <initializer_list>
void
test01()
{
std::begin({1, 2, 3});
std::end({1, 2, 3});
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 20.3.5.4, pair range access: [pair.range]
#include <utility>
#include <vector>
void
test01()
{
std::vector<double> v{1.0, 2.0, 3.0};
auto p = std::make_pair(v.begin(), v.end());
std::begin(p);
std::end(p);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 20.4.2.10, tuple range access: pair range access [tuple.range]
#include <tuple>
#include <vector>
void
test01()
{
std::vector<double> v{1.0, 2.0, 3.0};
auto t = std::make_tuple(v.begin(), v.end());
std::begin(t);
std::end(t);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <string>
void
test01()
{
std::string s("Hello, World!");
std::begin(s);
std::end(s);
#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring ws(L"Hello, World!");
std::begin(ws);
std::end(ws);
#endif
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <array>
void
test01()
{
std::array<int, 3> a{1, 2, 3};
std::begin(a);
std::end(a);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <deque>
void
test01()
{
std::deque<int> d{1, 2, 3};
std::begin(d);
std::end(d);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <forward_list>
void
test01()
{
std::forward_list<int> fl{1, 2, 3};
std::begin(fl);
std::end(fl);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <list>
void
test01()
{
std::list<int> l{1, 2, 3};
std::begin(l);
std::end(l);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <map>
void
test01()
{
std::map<int, double> m{{1, 1.0}, {2, 2.0}, {3, 3.0}};
std::begin(m);
std::end(m);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <map>
void
test01()
{
std::multimap<int, double> mm{{1, 1.0}, {2, 2.0}, {3, 3.0}};
std::begin(mm);
std::end(mm);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <set>
void
test01()
{
std::multiset<int> ms{1, 2, 3};
std::begin(ms);
std::end(ms);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <set>
void
test01()
{
std::set<int> s{1, 2, 3};
std::begin(s);
std::end(s);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <unordered_map>
void
test01()
{
std::unordered_map<int, double> um{{1, 1.0}, {2, 2.0}, {3, 3.0}};
std::begin(um);
std::end(um);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <unordered_map>
void
test01()
{
std::unordered_multimap<int, double> umm{{1, 1.0}, {2, 2.0}, {3, 3.0}};
std::begin(umm);
std::end(umm);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <unordered_set>
void
test01()
{
std::unordered_multiset<int> ums{1, 2, 3};
std::begin(ums);
std::end(ums);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <unordered_set>
void
test01()
{
std::unordered_set<int> us{1, 2, 3};
std::begin(us);
std::end(us);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <vector>
void
test01()
{
std::vector<double> v{1.0, 2.0, 3.0};
std::begin(v);
std::end(v);
std::vector<bool> vb{true, false, true};
std::begin(vb);
std::end(vb);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
namespace std
{
template<class C> auto begin(C& c) -> decltype(c.begin());
template<class C> auto begin(const C& c) -> decltype(c.begin());
template<class C> auto end(C& c) -> decltype(c.end());
template<class C> auto end(const C& c) -> decltype(c.end());
template<class T, size_t N> T* begin(T (&array)[N]);
template<class T, size_t N> T* end(T (&array)[N]);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <iterator>
void
test01()
{
int arr[3] = {1, 2, 3};
std::begin(arr);
std::end(arr);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 26.6.10 valarray range access: [valarray.range]
#include <valarray>
void
test01()
{
std::valarray<double> va{1.0, 2.0, 3.0};
std::begin(va);
std::end(va);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <regex>
void
test01()
{
std::smatch sm;
std::begin(sm);
std::end(sm);
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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 Pred 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.6.5, range access [iterator.range]
#include <ext/vstring.h>
void
test01()
{
__gnu_cxx::__vstring s("Hello, World!");
std::begin(s);
std::end(s);
#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_cxx::__wvstring ws(L"Hello, World!");
std::begin(ws);
std::end(ws);
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment