1// -*- C++ -*-
2//===----------------------- initializer_list -----------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_INITIALIZER_LIST
12#define _LIBCPP_INITIALIZER_LIST
13
14/*
15    initializer_list synopsis
16
17namespace std
18{
19
20template<class E>
21class initializer_list
22{
23public:
24    typedef E        value_type;
25    typedef const E& reference;
26    typedef const E& const_reference;
27    typedef size_t   size_type;
28
29    typedef const E* iterator;
30    typedef const E* const_iterator;
31
32    initializer_list() noexcept;
33
34    size_t   size()  const noexcept;
35    const E* begin() const noexcept;
36    const E* end()   const noexcept;
37};
38
39template<class E> const E* begin(initializer_list<E> il) noexcept;
40template<class E> const E* end(initializer_list<E> il) noexcept;
41
42}  // std
43
44*/
45
46#include <__config>
47#include <cstddef>
48
49#pragma GCC system_header
50
51namespace std  // purposefully not versioned
52{
53
54#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
55
56template<class _E>
57class _LIBCPP_VISIBLE initializer_list
58{
59    const _E* __begin_;
60    size_t    __size_;
61
62    _LIBCPP_ALWAYS_INLINE
63    initializer_list(const _E* __b, size_t __s) _NOEXCEPT
64        : __begin_(__b),
65          __size_(__s)
66        {}
67public:
68    typedef _E        value_type;
69    typedef const _E& reference;
70    typedef const _E& const_reference;
71    typedef size_t    size_type;
72
73    typedef const _E* iterator;
74    typedef const _E* const_iterator;
75
76    _LIBCPP_ALWAYS_INLINE initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
77
78    _LIBCPP_ALWAYS_INLINE size_t    size()  const _NOEXCEPT {return __size_;}
79    _LIBCPP_ALWAYS_INLINE const _E* begin() const _NOEXCEPT {return __begin_;}
80    _LIBCPP_ALWAYS_INLINE const _E* end()   const _NOEXCEPT {return __begin_ + __size_;}
81};
82
83template<class _E>
84inline _LIBCPP_INLINE_VISIBILITY
85const _E*
86begin(initializer_list<_E> __il) _NOEXCEPT
87{
88    return __il.begin();
89}
90
91template<class _E>
92inline _LIBCPP_INLINE_VISIBILITY
93const _E*
94end(initializer_list<_E> __il) _NOEXCEPT
95{
96    return __il.end();
97}
98
99#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
100
101}  // std
102
103#endif  // _LIBCPP_INITIALIZER_LIST
104