Index: include/llvm/ADT/STLExtras.h =================================================================== --- include/llvm/ADT/STLExtras.h +++ include/llvm/ADT/STLExtras.h @@ -1038,6 +1038,11 @@ return std::distance(Range.begin(), Range.end()); } +template +constexpr size_t size(const T (&array)[N]) noexcept { + return N; +} + //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// Index: unittests/ADT/STLExtrasTest.cpp =================================================================== --- unittests/ADT/STLExtrasTest.cpp +++ unittests/ADT/STLExtrasTest.cpp @@ -364,4 +364,10 @@ EXPECT_EQ(5, count); } +TEST(STLExtrasTest, ArraySize) { + int a1[] = {1, 2, 3, 4}; + + EXPECT_EQ(size(a1), 4); +} + } // namespace