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 17 namespace std 18 { 19 20 template<class E> 21 class initializer_list 22 { 23 public: 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 39 template<class E> const E* begin(initializer_list<E> il) noexcept; 40 template<class E> const E* end(initializer_list<E> il) noexcept; 41 42 } // std 43 44 */ 45 46 #include <__config> 47 #include <cstddef> 48 49 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 50 #pragma GCC system_header 51 #endif 52 53 namespace std // purposefully not versioned 54 { 55 56 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 57 58 template<class _Ep> 59 class _LIBCPP_VISIBLE initializer_list 60 { 61 const _Ep* __begin_; 62 size_t __size_; 63 64 _LIBCPP_ALWAYS_INLINE 65 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT 66 : __begin_(__b), 67 __size_(__s) 68 {} 69 public: 70 typedef _Ep value_type; 71 typedef const _Ep& reference; 72 typedef const _Ep& const_reference; 73 typedef size_t size_type; 74 75 typedef const _Ep* iterator; 76 typedef const _Ep* const_iterator; 77 78 _LIBCPP_ALWAYS_INLINE initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} 79 80 _LIBCPP_ALWAYS_INLINE size_t size() const _NOEXCEPT {return __size_;} 81 _LIBCPP_ALWAYS_INLINE const _Ep* begin() const _NOEXCEPT {return __begin_;} 82 _LIBCPP_ALWAYS_INLINE const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} 83 }; 84 85 template<class _Ep> 86 inline _LIBCPP_INLINE_VISIBILITY 87 const _Ep* 88 begin(initializer_list<_Ep> __il) _NOEXCEPT 89 { 90 return __il.begin(); 91 } 92 93 template<class _Ep> 94 inline _LIBCPP_INLINE_VISIBILITY 95 const _Ep* 96 end(initializer_list<_Ep> __il) _NOEXCEPT 97 { 98 return __il.end(); 99 } 100 101 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 102 103 } // std 104 105 #endif // _LIBCPP_INITIALIZER_LIST 106