initializer_list

Go to the documentation of this file.
00001 // std::initializer_list support -*- C++ -*-
00002 
00003 // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
00004 //
00005 // This file is part of GCC.
00006 //
00007 // GCC is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 //
00012 // GCC is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 /** @file initializer_list
00027  *  This is a Standard C++ Library header.
00028  */
00029 
00030 #ifndef _INITIALIZER_LIST
00031 #define _INITIALIZER_LIST
00032 
00033 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00034 
00035 #pragma GCC visibility push(default)
00036 
00037 #include <cstddef>
00038 
00039 namespace std
00040 {
00041   /// initializer_list
00042   template<class _E>
00043     class initializer_list
00044     {
00045     public:
00046       typedef _E        value_type;
00047       typedef const _E&     reference;
00048       typedef const _E&     const_reference;
00049       typedef size_t        size_type;
00050       typedef const _E*     iterator;
00051       typedef const _E*     const_iterator;
00052 
00053     private:
00054       iterator          _M_array;
00055       size_type         _M_len;
00056 
00057       // The compiler can call a private constructor.
00058       initializer_list(const_iterator __a, size_type __l)
00059       : _M_array(__a), _M_len(__l) { }
00060 
00061     public:
00062       initializer_list() : _M_array(NULL), _M_len(0) { }
00063 
00064       // Number of elements.
00065       size_type
00066       size() const { return _M_len; }
00067 
00068       // First element.
00069       const_iterator
00070       begin() const { return _M_array; }
00071 
00072       // One past the last element.
00073       const_iterator
00074       end() const { return begin() + size(); }
00075   };
00076 }
00077 
00078 #pragma GCC visibility pop
00079 #endif // C++0x
00080 #endif // _INITIALIZER_LIST

Generated on 11 Jan 2010 for libstdc++ by  doxygen 1.6.1