Array.h 704 B

1234567891011121314151617181920212223
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <array>
  4. #include <utility>
  5. namespace c10 {
  6. // This helper function creates a constexpr std::array
  7. // From a compile time list of values, without requiring you to explicitly
  8. // write out the length.
  9. //
  10. // See also https://stackoverflow.com/a/26351760/23845
  11. template <typename V, typename... T>
  12. inline constexpr auto array_of(T&&... t) -> std::array<V, sizeof...(T)> {
  13. return {{std::forward<T>(t)...}};
  14. }
  15. } // namespace c10
  16. #else
  17. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  18. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)