2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
2021-11-18 05:25:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_INITIALIZER_LIST
|
|
|
|
#define _LIBCPP_INITIALIZER_LIST
|
|
|
|
|
|
|
|
/*
|
|
|
|
initializer_list synopsis
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
template<class E>
|
|
|
|
class initializer_list
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef E value_type;
|
|
|
|
typedef const E& reference;
|
|
|
|
typedef const E& const_reference;
|
|
|
|
typedef size_t size_type;
|
|
|
|
|
|
|
|
typedef const E* iterator;
|
|
|
|
typedef const E* const_iterator;
|
|
|
|
|
2013-08-27 04:11:32 +08:00
|
|
|
initializer_list() noexcept; // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2013-08-27 04:11:32 +08:00
|
|
|
size_t size() const noexcept; // constexpr in C++14
|
|
|
|
const E* begin() const noexcept; // constexpr in C++14
|
|
|
|
const E* end() const noexcept; // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
2013-08-27 04:11:32 +08:00
|
|
|
template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
|
|
|
|
template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
|
2010-05-29 01:53:59 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-03-26 00:55:36 +08:00
|
|
|
#include <__assert> // all public C++ headers provide the assertion handler
|
2010-05-12 03:42:16 +08:00
|
|
|
#include <__config>
|
|
|
|
#include <cstddef>
|
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2022-02-02 09:16:40 +08:00
|
|
|
# pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
namespace std // purposefully not versioned
|
|
|
|
{
|
|
|
|
|
2017-04-19 07:09:36 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2011-08-13 05:56:02 +08:00
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template<class _Ep>
|
2017-01-05 07:56:00 +08:00
|
|
|
class _LIBCPP_TEMPLATE_VIS initializer_list
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
const _Ep* __begin_;
|
2010-05-12 03:42:16 +08:00
|
|
|
size_t __size_;
|
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-11-30 02:15:50 +08:00
|
|
|
initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
|
2010-05-12 03:42:16 +08:00
|
|
|
: __begin_(__b),
|
|
|
|
__size_(__s)
|
|
|
|
{}
|
|
|
|
public:
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef _Ep value_type;
|
|
|
|
typedef const _Ep& reference;
|
|
|
|
typedef const _Ep& const_reference;
|
2010-05-12 03:42:16 +08:00
|
|
|
typedef size_t size_type;
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef const _Ep* iterator;
|
|
|
|
typedef const _Ep* const_iterator;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
|
|
|
initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
|
|
|
size_t size() const _NOEXCEPT {return __size_;}
|
2019-05-30 00:01:36 +08:00
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
|
|
|
const _Ep* begin() const _NOEXCEPT {return __begin_;}
|
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
|
|
|
const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template<class _Ep>
|
2010-05-29 01:53:59 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-11-30 02:15:50 +08:00
|
|
|
const _Ep*
|
|
|
|
begin(initializer_list<_Ep> __il) _NOEXCEPT
|
2010-05-29 01:53:59 +08:00
|
|
|
{
|
|
|
|
return __il.begin();
|
|
|
|
}
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template<class _Ep>
|
2010-05-29 01:53:59 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2013-08-27 04:11:32 +08:00
|
|
|
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-11-30 02:15:50 +08:00
|
|
|
const _Ep*
|
|
|
|
end(initializer_list<_Ep> __il) _NOEXCEPT
|
2010-05-29 01:53:59 +08:00
|
|
|
{
|
|
|
|
return __il.end();
|
|
|
|
}
|
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // !defined(_LIBCPP_CXX03_LANG)
|
2011-08-13 05:56:02 +08:00
|
|
|
|
2021-12-02 21:12:51 +08:00
|
|
|
} // namespace std
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_INITIALIZER_LIST
|