Add missing && when forwarding args (#894)

Without the && args would be copied and perfect forwarding won't work.

Also add template utils to make sure the function only forwards array
and not vector<array>.
This commit is contained in:
Cheng
2024-03-26 06:55:54 +09:00
committed by GitHub
parent 8e686764ac
commit 28fcd2b519
4 changed files with 18 additions and 8 deletions

View File

@@ -510,4 +510,15 @@ void array::init(It src) {
}
}
/* Utilities for determining whether a template parameter is array. */
template <typename T>
inline constexpr bool is_array_v =
std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, array>;
template <typename... T>
inline constexpr bool is_arrays_v = (is_array_v<T> && ...);
template <typename... T>
using enable_for_arrays_t = typename std::enable_if_t<is_arrays_v<T...>>;
} // namespace mlx::core