pytorch/c10/util/Array.h
Edward Z. Yang 8195a0aaa7 Move array_of helper to c10/util (#116749)
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/116749
Approved by: https://github.com/drisspg, https://github.com/Skylion007
ghstack dependencies: #116685
2024-01-04 21:58:32 +00:00

16 lines
436 B
C++

#include <array>
#include <utility>
namespace c10 {
// This helper function creates a constexpr std::array
// From a compile time list of values, without requiring you to explicitly
// write out the length.
//
// See also https://stackoverflow.com/a/26351760/23845
template <typename V, typename... T>
inline constexpr auto array_of(T&&... t) -> std::array<V, sizeof...(T)> {
return {{std::forward<T>(t)...}};
}
} // namespace c10