diff --git a/include/xsimd/types/xsimd_batch_constant.hpp b/include/xsimd/types/xsimd_batch_constant.hpp index 4da2e3da6..0f5d4a978 100644 --- a/include/xsimd/types/xsimd_batch_constant.hpp +++ b/include/xsimd/types/xsimd_batch_constant.hpp @@ -408,6 +408,15 @@ namespace xsimd return {}; } +#if __cplusplus >= 202002L + template + XSIMD_INLINE constexpr batch_constant + make_batch_constant(std::index_sequence) noexcept + { + return {}; + } +#endif + template XSIMD_INLINE constexpr batch_bool_constant make_batch_bool_constant(std::index_sequence) noexcept @@ -422,6 +431,15 @@ namespace xsimd return {}; } +#if __cplusplus >= 202002L + template + XSIMD_INLINE constexpr batch_bool_constant + make_batch_bool_constant(std::index_sequence) noexcept + { + return {}; + } +#endif + } // namespace detail /** @@ -479,6 +497,21 @@ namespace xsimd return {}; } +#if __cplusplus >= 202002L + /** + * @brief Build a @c batch_constant from a std::array (C++20) + * + * @tparam Arr The std::array containing the values (non type template argument). + * @tparam A Architecture that will be used when converting to a regular batch. + */ + template + requires(Arr.size() == batch::size) + XSIMD_INLINE constexpr auto make_batch_constant() noexcept + { + return detail::make_batch_constant(std::make_index_sequence()); + } +#endif + /* * @brief Build a @c batch_bool_constant with a single repeated value. * @@ -491,6 +524,23 @@ namespace xsimd return {}; } +#if __cplusplus >= 202002L + /** + * @brief Build a @c batch_constant from a std::array of boolean (C++20) + * + * @tparam Arr The std::array containing the boolean values (non type template argument). + * @tparam A Architecture that will be used when converting to a regular batch. + */ + template + requires( + (Arr.size() == batch_bool::size) + && std::is_same_v) + XSIMD_INLINE constexpr auto make_batch_bool_constant() noexcept + { + return detail::make_batch_bool_constant(std::make_index_sequence()); + } +#endif + #endif namespace generator