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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___TYPE_TRAITS_EXTENT_H 10 #define _LIBCPP___TYPE_TRAITS_EXTENT_H 11 12 #include <__config> 13 #include <__type_traits/integral_constant.h> 14 #include <cstddef> 15 16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17 # pragma GCC system_header 18 #endif 19 20 _LIBCPP_BEGIN_NAMESPACE_STD 21 22 #if __has_keyword(__array_extent) 23 24 template<class _Tp, size_t _Dim = 0> 25 struct _LIBCPP_TEMPLATE_VIS extent 26 : integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; 27 28 #if _LIBCPP_STD_VER > 14 29 template <class _Tp, unsigned _Ip = 0> 30 inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); 31 #endif 32 33 #else // __has_keyword(__array_extent) 34 35 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent 36 : public integral_constant<size_t, 0> {}; 37 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> 38 : public integral_constant<size_t, 0> {}; 39 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> 40 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 41 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> 42 : public integral_constant<size_t, _Np> {}; 43 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> 44 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 45 46 #if _LIBCPP_STD_VER > 14 47 template <class _Tp, unsigned _Ip = 0> 48 inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; 49 #endif 50 51 #endif // __has_keyword(__array_extent) 52 53 _LIBCPP_END_NAMESPACE_STD 54 55 #endif // _LIBCPP___TYPE_TRAITS_EXTENT_H 56