114 lines · plain
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP_INITIALIZER_LIST11#define _LIBCPP_INITIALIZER_LIST12 13/*14 initializer_list synopsis15 16namespace std17{18 19template<class E>20class initializer_list21{22public:23 typedef E value_type;24 typedef const E& reference;25 typedef const E& const_reference;26 typedef size_t size_type;27 28 typedef const E* iterator;29 typedef const E* const_iterator;30 31 initializer_list() noexcept; // constexpr in C++1432 33 size_t size() const noexcept; // constexpr in C++1434 const E* begin() const noexcept; // constexpr in C++1435 const E* end() const noexcept; // constexpr in C++1436};37 38template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++1439template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++1440 41} // std42 43*/44 45#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)46# include <__cxx03/__config>47#else48# include <__config>49# include <__cstddef/size_t.h>50# include <version>51 52# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53# pragma GCC system_header54# endif55 56namespace std // purposefully not versioned57{58 59# ifndef _LIBCPP_CXX03_LANG60 61template <class _Ep>62class _LIBCPP_NO_SPECIALIZATIONS initializer_list {63 const _Ep* __begin_;64 size_t __size_;65 66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT67 : __begin_(__b),68 __size_(__s) {}69 70public:71 typedef _Ep value_type;72 typedef const _Ep& reference;73 typedef const _Ep& const_reference;74 typedef size_t size_type;75 76 typedef const _Ep* iterator;77 typedef const _Ep* const_iterator;78 79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}80 81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const _NOEXCEPT {82 return __size_;83 }84 85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const _NOEXCEPT {86 return __begin_;87 }88 89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const _NOEXCEPT {90 return __begin_ + __size_;91 }92};93 94template <class _Ep>95inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT {96 return __il.begin();97}98 99template <class _Ep>100inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT {101 return __il.end();102}103 104# endif // !defined(_LIBCPP_CXX03_LANG)105 106} // namespace std107 108# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20109# include <cstddef>110# endif111#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)112 113#endif // _LIBCPP_INITIALIZER_LIST114