diff --git a/include/CL/sycl/vendor/Xilinx/partition_array.hpp b/include/CL/sycl/vendor/Xilinx/partition_array.hpp index be2d49d83..e2484221a 100644 --- a/include/CL/sycl/vendor/Xilinx/partition_array.hpp +++ b/include/CL/sycl/vendor/Xilinx/partition_array.hpp @@ -15,6 +15,7 @@ #include #include +#include /** \addtogroup Xilinx Xilinx vendor extensions @{ @@ -190,30 +191,30 @@ struct partition_array { } - /// A constructor from another array of the same size - template - partition_array(const partition_array &src) - : partition_array{ } { - std::copy_n(&src[0], Size, &(*this)[0]); - } - - - /// Construct an array from a std::array - template - partition_array(const std::array &src) - : partition_array{ } { - std::copy_n(&src[0], Size, &(*this)[0]); + /// A constructor from some container + template + partition_array(const SomeContainer &src) + : partition_array { } { + /// \todo Find a way to specialize this with a safer + /// implementation when the size of src is at least constexpr + std::copy_n(std::begin(src), Size, begin()); } /// Construct an array from initializer_list - template - partition_array(std::initializer_list l) - : partition_array{ } { - std::size_t i = 0; - for (auto itr = l.begin(); itr != l.end(); itr++) - (*this)[i++] = *itr; + template a = { some_other_array } + typename = std::enable_if_t::value>> + constexpr partition_array(std::initializer_list l) + : partition_array { } { + /// \todo Find a way to specialize this with a safer + /// implementation when the size of src is at least constexpr + /// This does not work... + /// static_assert(l.size() == Size); + std::copy_n(std::begin(l), Size, begin()); } diff --git a/tests/array_partition/array_partition.cpp b/tests/array_partition/array_partition.cpp index be1937d10..23376a1f0 100644 --- a/tests/array_partition/array_partition.cpp +++ b/tests/array_partition/array_partition.cpp @@ -1,4 +1,4 @@ -;#include +#include #include #include #include @@ -23,7 +23,8 @@ void validateFunc (std::string name, ArrayType arr) { std::cout << "Size: " << arr.size() << std::endl; // Show partition type - std::cout << "Partition type: " << asInt(arr.get_partition_type()) << std::endl; + std::cout << "Partition type: " << asInt(arr.get_partition_type()) + << std::endl; // Test iterator std::cout << "Content from iterator: "; @@ -33,8 +34,8 @@ void validateFunc (std::string name, ArrayType arr) { // Test subscript operator std::cout << "Content from operator: "; - for (int i = 0; i < arr.size(); i++) - std::cout << arr[i] << " "; + for (auto e : arr) + std::cout << e << " "; std::cout << "\n"; } @@ -66,6 +67,10 @@ int main() { xilinx::partition::cyclic> F { E }; validateFunc("F", F); + F = C; + + validateFunc("FC", F); + // Block Partition for G xilinx::partition_array> G;