libstdc++
range_access.h
Go to the documentation of this file.
00001 // <range_access.h> -*- C++ -*-
00002 
00003 // Copyright (C) 2010 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file bits/range_access.h
00026  *  This is an internal header file, included by other library headers.
00027  *  Do not attempt to use it directly. @headername{iterator}
00028  */
00029 
00030 #ifndef _GLIBCXX_RANGE_ACCESS_H
00031 #define _GLIBCXX_RANGE_ACCESS_H 1
00032 
00033 #pragma GCC system_header
00034 
00035 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00036 
00037 namespace std _GLIBCXX_VISIBILITY(default)
00038 {
00039 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00040 
00041   /**
00042    *  @brief  Return an iterator pointing to the first element of
00043    *          the container.
00044    *  @param  __cont  Container.
00045    */
00046   template<class _Container>
00047     inline auto
00048     begin(_Container& __cont) -> decltype(__cont.begin())
00049     { return __cont.begin(); }
00050 
00051   /**
00052    *  @brief  Return an iterator pointing to the first element of
00053    *          the const container.
00054    *  @param  __cont  Container.
00055    */
00056   template<class _Container>
00057     inline auto
00058     begin(const _Container& __cont) -> decltype(__cont.begin())
00059     { return __cont.begin(); }
00060 
00061   /**
00062    *  @brief  Return an iterator pointing to one past the last element of
00063    *          the container.
00064    *  @param  __cont  Container.
00065    */
00066   template<class _Container>
00067     inline auto
00068     end(_Container& __cont) -> decltype(__cont.end())
00069     { return __cont.end(); }
00070 
00071   /**
00072    *  @brief  Return an iterator pointing to one past the last element of
00073    *          the const container.
00074    *  @param  __cont  Container.
00075    */
00076   template<class _Container>
00077     inline auto
00078     end(const _Container& __cont) -> decltype(__cont.end())
00079     { return __cont.end(); }
00080 
00081   /**
00082    *  @brief  Return an iterator pointing to the first element of the array.
00083    *  @param  __arr  Array.
00084    */
00085   template<class _Tp, size_t _Nm>
00086     inline _Tp*
00087     begin(_Tp (&__arr)[_Nm])
00088     { return __arr; }
00089 
00090   /**
00091    *  @brief  Return an iterator pointing to one past the last element
00092    *          of the array.
00093    *  @param  __arr  Array.
00094    */
00095   template<class _Tp, size_t _Nm>
00096     inline _Tp*
00097     end(_Tp (&__arr)[_Nm])
00098     { return __arr + _Nm; }
00099 
00100 _GLIBCXX_END_NAMESPACE_VERSION
00101 } // namespace
00102 
00103 #endif // __GXX_EXPERIMENTAL_CXX0X__
00104 
00105 #endif // _GLIBCXX_RANGE_ACCESS_H