2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / libstdc++-v3 / include / bits / range_access.h
blobe9bf67e499bcac6cd6b1d17528aebe8b4287849f
1 // <range_access.h> -*- C++ -*-
3 // Copyright (C) 2010 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file bits/range_access.h
26 * This is an internal header file, included by other library headers.
27 * You should not attempt to use it directly.
30 #ifndef _GLIBCXX_RANGE_ACCESS_H
31 #define _GLIBCXX_RANGE_ACCESS_H 1
33 #pragma GCC system_header
35 #ifdef __GXX_EXPERIMENTAL_CXX0X__
37 _GLIBCXX_BEGIN_NAMESPACE(std)
39 /**
40 * @brief Return an iterator pointing to the first element of
41 * the container.
42 * @param cont Container.
44 template<class _Container>
45 inline auto
46 begin(_Container& __cont) -> decltype(__cont.begin())
47 { return __cont.begin(); }
49 /**
50 * @brief Return an iterator pointing to the first element of
51 * the const container.
52 * @param cont Container.
54 template<class _Container>
55 inline auto
56 begin(const _Container& __cont) -> decltype(__cont.begin())
57 { return __cont.begin(); }
59 /**
60 * @brief Return an iterator pointing to one past the last element of
61 * the container.
62 * @param cont Container.
64 template<class _Container>
65 inline auto
66 end(_Container& __cont) -> decltype(__cont.end())
67 { return __cont.end(); }
69 /**
70 * @brief Return an iterator pointing to one past the last element of
71 * the const container.
72 * @param cont Container.
74 template<class _Container>
75 inline auto
76 end(const _Container& __cont) -> decltype(__cont.end())
77 { return __cont.end(); }
79 /**
80 * @brief Return an iterator pointing to the first element of the array.
81 * @param arr Array.
83 template<class _Tp, size_t _Nm>
84 inline _Tp*
85 begin(_Tp (&__arr)[_Nm])
86 { return __arr; }
88 /**
89 * @brief Return an iterator pointing to one past the last element
90 * of the array.
91 * @param arr Array.
93 template<class _Tp, size_t _Nm>
94 inline _Tp*
95 end(_Tp (&__arr)[_Nm])
96 { return __arr + _Nm; }
98 _GLIBCXX_END_NAMESPACE
100 #endif // __GXX_EXPERIMENTAL_CXX0X__
102 #endif // _GLIBCXX_RANGE_ACCESS_H