Skip to content

Commit

Permalink
New SimdArray ctor overloads to fix loads from C-arrays
Browse files Browse the repository at this point in the history
Fixes: gh-96
Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Dec 15, 2015
1 parent cbbb6d2 commit 2701e14
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions common/simdarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ class alignas(
static constexpr std::size_t N0 = my_traits::N0;
static constexpr std::size_t N1 = my_traits::N1;
using Split = Common::Split<N0>;
template <typename U, std::size_t K> using CArray = U[K];

public:
using storage_type0 = typename my_traits::storage_type0;
Expand Down Expand Up @@ -544,6 +545,27 @@ class alignas(
: data0(mem, f), data1(mem + storage_type0::size(), f)
{
}
/**\internal
* Load from a C-array. This is basically the same function as the load constructor
* above, except that the forwarding reference overload would steal the deal and the
* constructor above doesn't get called. This overload is required to enable loads
* from C-arrays.
*/
template <typename U, std::size_t Extent, typename Flags = DefaultLoadTag,
typename = enable_if<Traits::is_load_store_flag<Flags>::value>>
explicit Vc_INTRINSIC SimdArray(CArray<U, Extent> &mem, Flags f = Flags())
: data0(&mem[0], f), data1(&mem[storage_type0::size()], f)
{
}
/**\internal
* Const overload of the above.
*/
template <typename U, std::size_t Extent, typename Flags = DefaultLoadTag,
typename = enable_if<Traits::is_load_store_flag<Flags>::value>>
explicit Vc_INTRINSIC SimdArray(const CArray<U, Extent> &mem, Flags f = Flags())
: data0(&mem[0], f), data1(&mem[storage_type0::size()], f)
{
}

// initializer list
Vc_INTRINSIC SimdArray(const std::initializer_list<value_type> &init)
Expand Down

0 comments on commit 2701e14

Please sign in to comment.