Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __iterator / access.h
blob2782400ea771be6fffc3c4bf8771972dd8bf0b92
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-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ITERATOR_ACCESS_H
11 #define _LIBCPP___ITERATOR_ACCESS_H
13 #include <__config>
14 #include <cstddef>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
18 #endif
20 _LIBCPP_BEGIN_NAMESPACE_STD
22 template <class _Tp, size_t _Np>
23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* begin(_Tp (&__array)[_Np]) _NOEXCEPT {
24 return __array;
27 template <class _Tp, size_t _Np>
28 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* end(_Tp (&__array)[_Np]) _NOEXCEPT {
29 return __array + _Np;
32 #if !defined(_LIBCPP_CXX03_LANG)
34 template <class _Cp>
35 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
36 auto
37 begin(_Cp& __c) -> decltype(__c.begin())
39 return __c.begin();
42 template <class _Cp>
43 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
44 auto
45 begin(const _Cp& __c) -> decltype(__c.begin())
47 return __c.begin();
50 template <class _Cp>
51 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
52 auto
53 end(_Cp& __c) -> decltype(__c.end())
55 return __c.end();
58 template <class _Cp>
59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
60 auto
61 end(const _Cp& __c) -> decltype(__c.end())
63 return __c.end();
66 #if _LIBCPP_STD_VER >= 14
68 template <class _Cp>
69 _LIBCPP_HIDE_FROM_ABI constexpr auto cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c)))
70 -> decltype(std::begin(__c)) {
71 return std::begin(__c);
74 template <class _Cp>
75 _LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std::end(__c))) -> decltype(std::end(__c)) {
76 return std::end(__c);
79 #endif
82 #else // defined(_LIBCPP_CXX03_LANG)
84 template <class _Cp>
85 _LIBCPP_INLINE_VISIBILITY
86 typename _Cp::iterator
87 begin(_Cp& __c)
89 return __c.begin();
92 template <class _Cp>
93 _LIBCPP_INLINE_VISIBILITY
94 typename _Cp::const_iterator
95 begin(const _Cp& __c)
97 return __c.begin();
100 template <class _Cp>
101 _LIBCPP_INLINE_VISIBILITY
102 typename _Cp::iterator
103 end(_Cp& __c)
105 return __c.end();
108 template <class _Cp>
109 _LIBCPP_INLINE_VISIBILITY
110 typename _Cp::const_iterator
111 end(const _Cp& __c)
113 return __c.end();
116 #endif // !defined(_LIBCPP_CXX03_LANG)
118 _LIBCPP_END_NAMESPACE_STD
120 #endif // _LIBCPP___ITERATOR_ACCESS_H