xref: /aosp_15_r20/external/pytorch/c10/util/Array.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <array>
4 #include <utility>
5 
6 namespace c10 {
7 
8 // This helper function creates a constexpr std::array
9 // From a compile time list of values, without requiring you to explicitly
10 // write out the length.
11 //
12 // See also https://stackoverflow.com/a/26351760/23845
13 template <typename V, typename... T>
14 inline constexpr auto array_of(T&&... t) -> std::array<V, sizeof...(T)> {
15   return {{std::forward<T>(t)...}};
16 }
17 
18 } // namespace c10
19