Warning: This file is not a C or C++ file. It does not have highlighting.

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 <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>
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_builtin(__array_extent)
23
24template <class _Tp, size_t _Dim = 0>
25struct _LIBCPP_NO_SPECIALIZATIONS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
26
27# if _LIBCPP_STD_VER >= 17
28template <class _Tp, unsigned _Ip = 0>
29_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
30# endif
31
32#else // __has_builtin(__array_extent)
33
34template <class _Tp, unsigned _Ip = 0>
35struct extent : public integral_constant<size_t, 0> {};
36template <class _Tp>
37struct extent<_Tp[], 0> : public integral_constant<size_t, 0> {};
38template <class _Tp, unsigned _Ip>
39struct extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};
40template <class _Tp, size_t _Np>
41struct extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {};
42template <class _Tp, size_t _Np, unsigned _Ip>
43struct extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};
44
45# if _LIBCPP_STD_VER >= 17
46template <class _Tp, unsigned _Ip = 0>
47inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
48# endif
49
50#endif // __has_builtin(__array_extent)
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___TYPE_TRAITS_EXTENT_H
55

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__type_traits/extent.h