]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/libsupc++/initializer_list
Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / initializer_list
CommitLineData
09357846
JM
1// std::initializer_list support -*- C++ -*-
2
85ec4feb 3// Copyright (C) 2008-2018 Free Software Foundation, Inc.
09357846
JM
4//
5// This file is part of GCC.
6//
7// GCC is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
748086b7 9// the Free Software Foundation; either version 3, or (at your option)
09357846 10// any later version.
eaf4cf4f 11//
09357846
JM
12// GCC is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
eaf4cf4f 16//
748086b7
JJ
17// Under Section 7 of GPL version 3, you are granted additional
18// permissions described in the GCC Runtime Library Exception, version
19// 3.1, as published by the Free Software Foundation.
09357846 20
748086b7
JJ
21// You should have received a copy of the GNU General Public License and
22// a copy of the GCC Runtime Library Exception along with this program;
23// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24// <http://www.gnu.org/licenses/>.
09357846 25
ad68e9fc
BK
26/** @file initializer_list
27 * This is a Standard C++ Library header.
28 */
29
eaf4cf4f
BK
30#ifndef _INITIALIZER_LIST
31#define _INITIALIZER_LIST
09357846 32
584fd146
PC
33#pragma GCC system_header
34
734f5023 35#if __cplusplus < 201103L
a7d5d7e2 36# include <bits/c++0x_warning.h>
8972079e 37#else // C++0x
6010fae7 38
09357846
JM
39#pragma GCC visibility push(default)
40
8fc81078 41#include <bits/c++config.h>
09357846
JM
42
43namespace std
44{
ad68e9fc 45 /// initializer_list
6010fae7 46 template<class _E>
d07660cc
PC
47 class initializer_list
48 {
d07660cc 49 public:
eaf4cf4f
BK
50 typedef _E value_type;
51 typedef const _E& reference;
52 typedef const _E& const_reference;
53 typedef size_t size_type;
54 typedef const _E* iterator;
55 typedef const _E* const_iterator;
ffa52e11 56
eaf4cf4f
BK
57 private:
58 iterator _M_array;
59 size_type _M_len;
ffa52e11 60
eaf4cf4f 61 // The compiler can call a private constructor.
900484de 62 constexpr initializer_list(const_iterator __a, size_type __l)
eaf4cf4f 63 : _M_array(__a), _M_len(__l) { }
ffa52e11 64
eaf4cf4f 65 public:
5d861bf2
PC
66 constexpr initializer_list() noexcept
67 : _M_array(0), _M_len(0) { }
d07660cc
PC
68
69 // Number of elements.
900484de 70 constexpr size_type
5d861bf2 71 size() const noexcept { return _M_len; }
d07660cc
PC
72
73 // First element.
900484de 74 constexpr const_iterator
5d861bf2 75 begin() const noexcept { return _M_array; }
d07660cc
PC
76
77 // One past the last element.
900484de 78 constexpr const_iterator
5d861bf2 79 end() const noexcept { return begin() + size(); }
3c523cf8 80 };
f67a9881
PC
81
82 /**
83 * @brief Return an iterator pointing to the first element of
1e8c4907 84 * the initializer_list.
93c66bc6 85 * @param __ils Initializer list.
f67a9881
PC
86 */
87 template<class _Tp>
900484de 88 constexpr const _Tp*
5d861bf2 89 begin(initializer_list<_Tp> __ils) noexcept
f67a9881
PC
90 { return __ils.begin(); }
91
92 /**
93 * @brief Return an iterator pointing to one past the last element
1e8c4907 94 * of the initializer_list.
93c66bc6 95 * @param __ils Initializer list.
f67a9881
PC
96 */
97 template<class _Tp>
900484de 98 constexpr const _Tp*
5d861bf2 99 end(initializer_list<_Tp> __ils) noexcept
f67a9881 100 { return __ils.end(); }
09357846
JM
101}
102
103#pragma GCC visibility pop
8972079e 104
734f5023 105#endif // C++11
8972079e 106
eaf4cf4f 107#endif // _INITIALIZER_LIST