1 //===- llvm/ADT/STLArrayExtras.h - additions to <array> ---------*- C++ -*-===//
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 // This file contains some templates that are useful if you are working with the
10 // STL at all.
11 //
12 // No library is required when using these functions.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_ADT_STLARRAYEXTRAS_H
17 #define LLVM_ADT_STLARRAYEXTRAS_H
18
19 #include <cstddef>
20
21 namespace llvm {
22
23 //===----------------------------------------------------------------------===//
24 // Extra additions for arrays
25 //===----------------------------------------------------------------------===//
26
27 /// Find the length of an array.
28 template <class T, std::size_t N>
array_lengthof(T (&)[N])29 constexpr inline size_t array_lengthof(T (&)[N]) {
30 return N;
31 }
32
33 } // end namespace llvm
34
35 #endif // LLVM_ADT_STLARRAYEXTRAS_H
36