Path: blob/main/contrib/llvm-project/libcxx/include/__iterator/access.h
35233 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___ITERATOR_ACCESS_H10#define _LIBCPP___ITERATOR_ACCESS_H1112#include <__config>13#include <cstddef>1415#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16# pragma GCC system_header17#endif1819_LIBCPP_BEGIN_NAMESPACE_STD2021template <class _Tp, size_t _Np>22_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* begin(_Tp (&__array)[_Np]) _NOEXCEPT {23return __array;24}2526template <class _Tp, size_t _Np>27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* end(_Tp (&__array)[_Np]) _NOEXCEPT {28return __array + _Np;29}3031#if !defined(_LIBCPP_CXX03_LANG)3233template <class _Cp>34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(_Cp& __c) -> decltype(__c.begin()) {35return __c.begin();36}3738template <class _Cp>39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(const _Cp& __c) -> decltype(__c.begin()) {40return __c.begin();41}4243template <class _Cp>44_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(_Cp& __c) -> decltype(__c.end()) {45return __c.end();46}4748template <class _Cp>49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> decltype(__c.end()) {50return __c.end();51}5253# if _LIBCPP_STD_VER >= 145455template <class _Cp>56_LIBCPP_HIDE_FROM_ABI constexpr auto57cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) -> decltype(std::begin(__c)) {58return std::begin(__c);59}6061template <class _Cp>62_LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std::end(__c))) -> decltype(std::end(__c)) {63return std::end(__c);64}6566# endif6768#else // defined(_LIBCPP_CXX03_LANG)6970template <class _Cp>71_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) {72return __c.begin();73}7475template <class _Cp>76_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator begin(const _Cp& __c) {77return __c.begin();78}7980template <class _Cp>81_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator end(_Cp& __c) {82return __c.end();83}8485template <class _Cp>86_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) {87return __c.end();88}8990#endif // !defined(_LIBCPP_CXX03_LANG)9192_LIBCPP_END_NAMESPACE_STD9394#endif // _LIBCPP___ITERATOR_ACCESS_H959697