xref: /openbsd-src/gnu/llvm/libcxx/include/__iterator/access.h (revision 4bdff4bed0e3d54e55670334c7d0077db4170f86)
176d0caaeSpatrick // -*- C++ -*-
276d0caaeSpatrick //===----------------------------------------------------------------------===//
376d0caaeSpatrick //
476d0caaeSpatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
576d0caaeSpatrick // See https://llvm.org/LICENSE.txt for license information.
676d0caaeSpatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
776d0caaeSpatrick //
876d0caaeSpatrick //===----------------------------------------------------------------------===//
976d0caaeSpatrick 
1076d0caaeSpatrick #ifndef _LIBCPP___ITERATOR_ACCESS_H
1176d0caaeSpatrick #define _LIBCPP___ITERATOR_ACCESS_H
1276d0caaeSpatrick 
1376d0caaeSpatrick #include <__config>
1476d0caaeSpatrick #include <cstddef>
1576d0caaeSpatrick 
1676d0caaeSpatrick #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1776d0caaeSpatrick #  pragma GCC system_header
1876d0caaeSpatrick #endif
1976d0caaeSpatrick 
2076d0caaeSpatrick _LIBCPP_BEGIN_NAMESPACE_STD
2176d0caaeSpatrick 
2276d0caaeSpatrick template <class _Tp, size_t _Np>
23*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
2476d0caaeSpatrick _Tp*
begin(_Tp (& __array)[_Np])2576d0caaeSpatrick begin(_Tp (&__array)[_Np])
2676d0caaeSpatrick {
2776d0caaeSpatrick     return __array;
2876d0caaeSpatrick }
2976d0caaeSpatrick 
3076d0caaeSpatrick template <class _Tp, size_t _Np>
31*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3276d0caaeSpatrick _Tp*
end(_Tp (& __array)[_Np])3376d0caaeSpatrick end(_Tp (&__array)[_Np])
3476d0caaeSpatrick {
3576d0caaeSpatrick     return __array + _Np;
3676d0caaeSpatrick }
3776d0caaeSpatrick 
3876d0caaeSpatrick #if !defined(_LIBCPP_CXX03_LANG)
3976d0caaeSpatrick 
4076d0caaeSpatrick template <class _Cp>
41*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4276d0caaeSpatrick auto
4376d0caaeSpatrick begin(_Cp& __c) -> decltype(__c.begin())
4476d0caaeSpatrick {
4576d0caaeSpatrick     return __c.begin();
4676d0caaeSpatrick }
4776d0caaeSpatrick 
4876d0caaeSpatrick template <class _Cp>
49*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
5076d0caaeSpatrick auto
5176d0caaeSpatrick begin(const _Cp& __c) -> decltype(__c.begin())
5276d0caaeSpatrick {
5376d0caaeSpatrick     return __c.begin();
5476d0caaeSpatrick }
5576d0caaeSpatrick 
5676d0caaeSpatrick template <class _Cp>
57*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
5876d0caaeSpatrick auto
5976d0caaeSpatrick end(_Cp& __c) -> decltype(__c.end())
6076d0caaeSpatrick {
6176d0caaeSpatrick     return __c.end();
6276d0caaeSpatrick }
6376d0caaeSpatrick 
6476d0caaeSpatrick template <class _Cp>
65*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
6676d0caaeSpatrick auto
6776d0caaeSpatrick end(const _Cp& __c) -> decltype(__c.end())
6876d0caaeSpatrick {
6976d0caaeSpatrick     return __c.end();
7076d0caaeSpatrick }
7176d0caaeSpatrick 
7276d0caaeSpatrick #if _LIBCPP_STD_VER > 11
7376d0caaeSpatrick 
7476d0caaeSpatrick template <class _Cp>
75*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
7676d0caaeSpatrick auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
7776d0caaeSpatrick {
7876d0caaeSpatrick     return _VSTD::begin(__c);
7976d0caaeSpatrick }
8076d0caaeSpatrick 
8176d0caaeSpatrick template <class _Cp>
82*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
8376d0caaeSpatrick auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
8476d0caaeSpatrick {
8576d0caaeSpatrick     return _VSTD::end(__c);
8676d0caaeSpatrick }
8776d0caaeSpatrick 
8876d0caaeSpatrick #endif
8976d0caaeSpatrick 
9076d0caaeSpatrick 
9176d0caaeSpatrick #else  // defined(_LIBCPP_CXX03_LANG)
9276d0caaeSpatrick 
9376d0caaeSpatrick template <class _Cp>
9476d0caaeSpatrick _LIBCPP_INLINE_VISIBILITY
9576d0caaeSpatrick typename _Cp::iterator
begin(_Cp & __c)9676d0caaeSpatrick begin(_Cp& __c)
9776d0caaeSpatrick {
9876d0caaeSpatrick     return __c.begin();
9976d0caaeSpatrick }
10076d0caaeSpatrick 
10176d0caaeSpatrick template <class _Cp>
10276d0caaeSpatrick _LIBCPP_INLINE_VISIBILITY
10376d0caaeSpatrick typename _Cp::const_iterator
begin(const _Cp & __c)10476d0caaeSpatrick begin(const _Cp& __c)
10576d0caaeSpatrick {
10676d0caaeSpatrick     return __c.begin();
10776d0caaeSpatrick }
10876d0caaeSpatrick 
10976d0caaeSpatrick template <class _Cp>
11076d0caaeSpatrick _LIBCPP_INLINE_VISIBILITY
11176d0caaeSpatrick typename _Cp::iterator
end(_Cp & __c)11276d0caaeSpatrick end(_Cp& __c)
11376d0caaeSpatrick {
11476d0caaeSpatrick     return __c.end();
11576d0caaeSpatrick }
11676d0caaeSpatrick 
11776d0caaeSpatrick template <class _Cp>
11876d0caaeSpatrick _LIBCPP_INLINE_VISIBILITY
11976d0caaeSpatrick typename _Cp::const_iterator
end(const _Cp & __c)12076d0caaeSpatrick end(const _Cp& __c)
12176d0caaeSpatrick {
12276d0caaeSpatrick     return __c.end();
12376d0caaeSpatrick }
12476d0caaeSpatrick 
12576d0caaeSpatrick #endif // !defined(_LIBCPP_CXX03_LANG)
12676d0caaeSpatrick 
12776d0caaeSpatrick _LIBCPP_END_NAMESPACE_STD
12876d0caaeSpatrick 
12976d0caaeSpatrick #endif // _LIBCPP___ITERATOR_ACCESS_H
130