STLArrayExtras.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/ADT/STLArrayExtras.h - additions to <array> ---------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains some templates that are useful if you are working with the
  15. // STL at all.
  16. //
  17. // No library is required when using these functions.
  18. //
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_ADT_STLARRAYEXTRAS_H
  21. #define LLVM_ADT_STLARRAYEXTRAS_H
  22. #include <cstddef>
  23. namespace llvm {
  24. //===----------------------------------------------------------------------===//
  25. // Extra additions for arrays
  26. //===----------------------------------------------------------------------===//
  27. /// Find the length of an array.
  28. template <class T, std::size_t N>
  29. constexpr inline size_t array_lengthof(T (&)[N]) {
  30. return N;
  31. }
  32. } // end namespace llvm
  33. #endif // LLVM_ADT_STLARRAYEXTRAS_H
  34. #ifdef __GNUC__
  35. #pragma GCC diagnostic pop
  36. #endif