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();
33
34    size_t   size()  const;
35    const E* begin() const;
36    const E* end()   const;
37};
38
39template<class E> const E* begin(initializer_list<E> il);
40template<class E> const E* end(initializer_list<E> il);
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
54template<class _E>
55class _LIBCPP_VISIBLE initializer_list
56{
57    const _E* __begin_;
58    size_t    __size_;
59
60    _LIBCPP_ALWAYS_INLINE
61    initializer_list(const _E* __b, size_t __s)
62        : __begin_(__b),
63          __size_(__s)
64        {}
65public:
66    typedef _E        value_type;
67    typedef const _E& reference;
68    typedef const _E& const_reference;
69    typedef size_t    size_type;
70
71    typedef const _E* iterator;
72    typedef const _E* const_iterator;
73
74    _LIBCPP_ALWAYS_INLINE initializer_list() : __begin_(nullptr), __size_(0) {}
75
76    _LIBCPP_ALWAYS_INLINE size_t    size()  const {return __size_;}
77    _LIBCPP_ALWAYS_INLINE const _E* begin() const {return __begin_;}
78    _LIBCPP_ALWAYS_INLINE const _E* end()   const {return __begin_ + __size_;}
79};
80
81template<class _E>
82inline _LIBCPP_INLINE_VISIBILITY
83const _E*
84begin(initializer_list<_E> __il)
85{
86    return __il.begin();
87}
88
89template<class _E>
90inline _LIBCPP_INLINE_VISIBILITY
91const _E*
92end(initializer_list<_E> __il)
93{
94    return __il.end();
95}
96
97}  // std
98
99#endif  // _LIBCPP_INITIALIZER_LIST
100