initializer_list revision 261272
120253Sjoerg// -*- C++ -*- 220302Sjoerg//===----------------------- initializer_list -----------------------------===// 320302Sjoerg// 420253Sjoerg// The LLVM Compiler Infrastructure 520253Sjoerg// 620253Sjoerg// This file is dual licensed under the MIT and the University of Illinois Open 720253Sjoerg// Source Licenses. See LICENSE.TXT for details. 820253Sjoerg// 920302Sjoerg//===----------------------------------------------------------------------===// 1020253Sjoerg 1120253Sjoerg#ifndef _LIBCPP_INITIALIZER_LIST 1220253Sjoerg#define _LIBCPP_INITIALIZER_LIST 1320253Sjoerg 1420302Sjoerg/* 1520253Sjoerg initializer_list synopsis 1620253Sjoerg 1720302Sjoergnamespace std 1820253Sjoerg{ 1920253Sjoerg 2020253Sjoergtemplate<class E> 2120253Sjoergclass initializer_list 2220253Sjoerg{ 2320253Sjoergpublic: 2420253Sjoerg typedef E value_type; 2520253Sjoerg typedef const E& reference; 2620302Sjoerg typedef const E& const_reference; 2720253Sjoerg typedef size_t size_type; 2820253Sjoerg 2920253Sjoerg typedef const E* iterator; 3020253Sjoerg typedef const E* const_iterator; 3120253Sjoerg 3220253Sjoerg initializer_list() noexcept; // constexpr in C++14 3320267Sjoerg 3420253Sjoerg size_t size() const noexcept; // constexpr in C++14 3520267Sjoerg const E* begin() const noexcept; // constexpr in C++14 3620267Sjoerg const E* end() const noexcept; // constexpr in C++14 3720267Sjoerg}; 3820267Sjoerg 3920267Sjoergtemplate<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14 4020267Sjoergtemplate<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14 4120267Sjoerg 4220253Sjoerg} // std 4320253Sjoerg 4420253Sjoerg*/ 4520253Sjoerg 4620253Sjoerg#include <__config> 4720253Sjoerg#include <cstddef> 4820253Sjoerg 4920253Sjoerg#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5020253Sjoerg#pragma GCC system_header 5120253Sjoerg#endif 5220253Sjoerg 5320253Sjoergnamespace std // purposefully not versioned 5420253Sjoerg{ 5520253Sjoerg 5620253Sjoerg#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 5720253Sjoerg 5820253Sjoergtemplate<class _Ep> 5920253Sjoergclass _LIBCPP_TYPE_VIS_ONLY initializer_list 6020267Sjoerg{ 6120267Sjoerg const _Ep* __begin_; 6220267Sjoerg size_t __size_; 6320267Sjoerg 6420267Sjoerg _LIBCPP_ALWAYS_INLINE 6520267Sjoerg _LIBCPP_CONSTEXPR_AFTER_CXX11 6620267Sjoerg initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT 6720267Sjoerg : __begin_(__b), 6820267Sjoerg __size_(__s) 6920267Sjoerg {} 7020267Sjoergpublic: 7120267Sjoerg typedef _Ep value_type; 7220267Sjoerg typedef const _Ep& reference; 7320267Sjoerg typedef const _Ep& const_reference; 7420253Sjoerg typedef size_t size_type; 7520253Sjoerg 7620253Sjoerg typedef const _Ep* iterator; 7720253Sjoerg typedef const _Ep* const_iterator; 7820253Sjoerg 7920253Sjoerg _LIBCPP_ALWAYS_INLINE 8020253Sjoerg _LIBCPP_CONSTEXPR_AFTER_CXX11 8120253Sjoerg initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} 8220253Sjoerg 8320253Sjoerg _LIBCPP_ALWAYS_INLINE 8420253Sjoerg _LIBCPP_CONSTEXPR_AFTER_CXX11 8520253Sjoerg size_t size() const _NOEXCEPT {return __size_;} 8620253Sjoerg 8720253Sjoerg _LIBCPP_ALWAYS_INLINE 8820253Sjoerg _LIBCPP_CONSTEXPR_AFTER_CXX11 8920253Sjoerg const _Ep* begin() const _NOEXCEPT {return __begin_;} 9020253Sjoerg 9120253Sjoerg _LIBCPP_ALWAYS_INLINE 9220253Sjoerg _LIBCPP_CONSTEXPR_AFTER_CXX11 9320253Sjoerg const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} 9420253Sjoerg}; 9520253Sjoerg 9620253Sjoergtemplate<class _Ep> 9720253Sjoerginline _LIBCPP_INLINE_VISIBILITY 9820253Sjoerg_LIBCPP_CONSTEXPR_AFTER_CXX11 9920253Sjoergconst _Ep* 10020253Sjoergbegin(initializer_list<_Ep> __il) _NOEXCEPT 10120253Sjoerg{ 10220253Sjoerg return __il.begin(); 10320253Sjoerg} 10420253Sjoerg 10520253Sjoergtemplate<class _Ep> 10620253Sjoerginline _LIBCPP_INLINE_VISIBILITY 10720253Sjoerg_LIBCPP_CONSTEXPR_AFTER_CXX11 10820253Sjoergconst _Ep* 10920253Sjoergend(initializer_list<_Ep> __il) _NOEXCEPT 11020267Sjoerg{ 11120253Sjoerg return __il.end(); 11220253Sjoerg} 11320253Sjoerg 11420253Sjoerg#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 11520253Sjoerg 11620253Sjoerg} // std 11720253Sjoerg 11820253Sjoerg#endif // _LIBCPP_INITIALIZER_LIST 11920253Sjoerg