Array.h 450 B

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