Skip to content

Commit

Permalink
MSVC: Move reinterpret_components_cast below Vector<T, Abi>
Browse files Browse the repository at this point in the history
MSVC requires Vector<T, Abi> to be defined before it's used in the
definition of the reinterpret_components_cast template function.
Reordering the code works around the issue.

Refs: gh-119
Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Sep 20, 2016
1 parent bdf21e4 commit 5204a2f
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions common/vector.h
Expand Up @@ -104,36 +104,6 @@ Vc_INTRINSIC Vc_CONST typename Vector<T, Abi>::MaskType isnegative(Vector<T, Abi
return x < Vector<T, Abi>::Zero();
}

/**
* \ingroup Utilities
* Constructs a new Vector object of type \p V from the Vector \p x, reinterpreting the
* bits of \p x for the new type \p V.
*
* This function is only applicable if:
* - the \c sizeof of the input and output types is equal
* - the Vector::size() of the input and output types is equal
* - the \c VectorEntryTypes of input and output have equal \c sizeof
*
* \tparam V The requested type to change \p x into.
* \param x The Vector to reinterpret as an object of type \p V.
* \returns A new object (rvalue) of type \p V.
*
* \warning This cast is non-portable since the applicability (see above) may change
* depending on the default vector types of the target platform. The function is perfectly
* safe to use with fully specified \p Abi, though.
*/
template <typename V, typename T, typename Abi>
Vc_ALWAYS_INLINE Vc_CONST enable_if<
(V::size() == Vector<T, Abi>::size() &&
sizeof(typename V::VectorEntryType) ==
sizeof(typename Vector<T, Abi>::VectorEntryType) &&
sizeof(V) == sizeof(Vector<T, Abi>) && alignof(V) <= alignof(Vector<T, Abi>)),
V>
reinterpret_components_cast(const Vector<T, Abi> &x)
{
return reinterpret_cast<const V &>(x);
}

/**
* \class Vector types.h <Vc/vector.h>
* \ingroup Vectors
Expand Down Expand Up @@ -832,6 +802,36 @@ template<typename T, typename Abi = VectorAbi::Best<T>> class Vector
VectorType d;
};

/**
* \ingroup Utilities
* Constructs a new Vector object of type \p V from the Vector \p x, reinterpreting the
* bits of \p x for the new type \p V.
*
* This function is only applicable if:
* - the \c sizeof of the input and output types is equal
* - the Vector::size() of the input and output types is equal
* - the \c VectorEntryTypes of input and output have equal \c sizeof
*
* \tparam V The requested type to change \p x into.
* \param x The Vector to reinterpret as an object of type \p V.
* \returns A new object (rvalue) of type \p V.
*
* \warning This cast is non-portable since the applicability (see above) may change
* depending on the default vector types of the target platform. The function is perfectly
* safe to use with fully specified \p Abi, though.
*/
template <typename V, typename T, typename Abi>
Vc_ALWAYS_INLINE Vc_CONST enable_if<
(V::size() == Vector<T, Abi>::size() &&
sizeof(typename V::VectorEntryType) ==
sizeof(typename Vector<T, Abi>::VectorEntryType) &&
sizeof(V) == sizeof(Vector<T, Abi>) && alignof(V) <= alignof(Vector<T, Abi>)),
V>
reinterpret_components_cast(const Vector<T, Abi> &x)
{
return reinterpret_cast<const V &>(x);
}

#define Vc_OP(symbol) \
template <typename T, typename Abi> \
inline Vector<T, Abi> &operator symbol##=(Vector<T, Abi> &, \
Expand Down

0 comments on commit 5204a2f

Please sign in to comment.