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