This has the benefit of consistent placement for these macros (outside the namespace, not inside it). This, in turn, makes it more obvious that the condition applies to the entire namespace scope. Compile times are also reduced a bit, since the compiler doesn't have to open a namespace just to close it again. This is enforced with a clang-tidy check. As a drive-by this also fixes a few macro comments.
113 lines
3.1 KiB
C++
113 lines
3.1 KiB
C++
// -*- C++ -*-
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#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;
|
|
|
|
initializer_list() noexcept; // constexpr in C++14
|
|
|
|
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
|
|
};
|
|
|
|
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
|
|
|
|
} // std
|
|
|
|
*/
|
|
|
|
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
|
|
# include <__cxx03/__config>
|
|
#else
|
|
# include <__config>
|
|
# include <__cstddef/size_t.h>
|
|
# include <version>
|
|
|
|
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
# pragma GCC system_header
|
|
# endif
|
|
|
|
# ifndef _LIBCPP_CXX03_LANG
|
|
|
|
namespace std // purposefully not versioned
|
|
{
|
|
|
|
template <class _Ep>
|
|
class _LIBCPP_NO_SPECIALIZATIONS initializer_list {
|
|
const _Ep* __begin_;
|
|
size_t __size_;
|
|
|
|
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
|
|
: __begin_(__b),
|
|
__size_(__s) {}
|
|
|
|
public:
|
|
typedef _Ep value_type;
|
|
typedef const _Ep& reference;
|
|
typedef const _Ep& const_reference;
|
|
typedef size_t size_type;
|
|
|
|
typedef const _Ep* iterator;
|
|
typedef const _Ep* const_iterator;
|
|
|
|
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
|
|
|
|
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const _NOEXCEPT {
|
|
return __size_;
|
|
}
|
|
|
|
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const _NOEXCEPT {
|
|
return __begin_;
|
|
}
|
|
|
|
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const _NOEXCEPT {
|
|
return __begin_ + __size_;
|
|
}
|
|
};
|
|
|
|
template <class _Ep>
|
|
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT {
|
|
return __il.begin();
|
|
}
|
|
|
|
template <class _Ep>
|
|
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT {
|
|
return __il.end();
|
|
}
|
|
|
|
} // namespace std
|
|
|
|
# endif // _LIBCPP_CXX03_LANG
|
|
|
|
# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
|
|
# include <cstddef>
|
|
# endif
|
|
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
|
|
|
|
#endif // _LIBCPP_INITIALIZER_LIST
|