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  *  You should not attempt to use it directly.
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 _GLIBCXX_BEGIN_NAMESPACE(std)
00038 
00039   /**
00040    *  @brief  Return an iterator pointing to the first element of
00041    *          the container.
00042    *  @param  cont  Container.
00043    */
00044   template<class _Container>
00045     inline auto
00046     begin(_Container& __cont) -> decltype(__cont.begin())
00047     { return __cont.begin(); }
00048 
00049   /**
00050    *  @brief  Return an iterator pointing to the first element of
00051    *          the const container.
00052    *  @param  cont  Container.
00053    */
00054   template<class _Container>
00055     inline auto
00056     begin(const _Container& __cont) -> decltype(__cont.begin())
00057     { return __cont.begin(); }
00058 
00059   /**
00060    *  @brief  Return an iterator pointing to one past the last element of
00061    *          the container.
00062    *  @param  cont  Container.
00063    */
00064   template<class _Container>
00065     inline auto
00066     end(_Container& __cont) -> decltype(__cont.end())
00067     { return __cont.end(); }
00068 
00069   /**
00070    *  @brief  Return an iterator pointing to one past the last element of
00071    *          the const container.
00072    *  @param  cont  Container.
00073    */
00074   template<class _Container>
00075     inline auto
00076     end(const _Container& __cont) -> decltype(__cont.end())
00077     { return __cont.end(); }
00078 
00079   /**
00080    *  @brief  Return an iterator pointing to the first element of the array.
00081    *  @param  arr  Array.
00082    */
00083   template<class _Tp, size_t _Nm>
00084     inline _Tp*
00085     begin(_Tp (&__arr)[_Nm])
00086     { return __arr; }
00087 
00088   /**
00089    *  @brief  Return an iterator pointing to one past the last element
00090    *          of the array.
00091    *  @param  arr  Array.
00092    */
00093   template<class _Tp, size_t _Nm>
00094     inline _Tp*
00095     end(_Tp (&__arr)[_Nm])
00096     { return __arr + _Nm; }
00097 
00098 _GLIBCXX_END_NAMESPACE
00099 
00100 #endif // __GXX_EXPERIMENTAL_CXX0X__
00101 
00102 #endif // _GLIBCXX_RANGE_ACCESS_H