# Type Conversion

Cast:

`batch_cast()` | `static_cast` on batch types
`bitwise_cast()` | `reinterpret_cast` on batch types
`batch_bool_cast()` | `static_cast` on batch predicate types

Conversion:

`to_float()` | per slot conversion to floating point
`to_int()` | per slot conversion to integer
`widen()` | per slot conversion to twice as big type

template<class T_out, class T_in, class A>
inline batch_bool<T_out, A> batch_bool_cast(batch_bool<T_in, A> const &x) noexcept

  Perform a static_cast from `T_in` to `T_out` on `x`.

  Parameters:

    x – batch_bool of `T_in`

  Returns:

    `x` cast to `T_out`

template<class T_out, class T_in, class A>
inline batch<T_out, A> batch_cast(batch<T_in, A> const &x) noexcept

  Perform a static_cast from `T_in` to `T_out` on `x`.

  Parameters:

    x – batch of `T_in`

  Returns:

    `x` cast to `T_out`

template<class T_out, class T_in, class A>
inline batch<T_out, A> bitwise_cast(batch<T_in, A> const &x) noexcept

  Perform a reinterpret_cast from `T_in` to `T_out` on `x`.

  Parameters:

    x – batch of `T_in`

  Returns:

    `x` reinterpreted as `T_out`

template<class T, class A>
inline batch<as_float_t<T>, A> to_float(batch<T, A> const &i) noexcept

  Perform a conversion from `i` to a value of an floating point type of the same size as `T`.

  This is equivalent to `batch_cast<as_float_t<T>>(i)`

  Parameters:

    i – batch of integers.

  Returns:

    `i` converted to a value of an floating point type of the same size as `T`

template<class T, class A>
inline batch<as_integer_t<T>, A> to_int(batch<T, A> const &x) noexcept

  Perform a conversion from `x` to a value of an integer type of the same size as `T` This is equivalent to `batch_cast<as_integer_t<T>>(x)`.

  Parameters:

    x – batch.

  Returns:

    `x` converted to a value of an integer type of the same size as `T`

template<class T, class A, typename std::enable_if<std::is_integral<T>::value, int>::type = 3>
inline batch<T, A> bitwise_cast(batch_bool<T, A> const &self) noexcept

  Cast a `batch_bool` of `T` into a `batch` of the same type using the following rule: if an element of `self` is true, it maps to -1 in the returned integral batch, otherwise it maps to 0.

  Parameters:

    self – batch_bool of `T`

  Returns:

    `self` cast to a `batch` of `T`

template<class T, class A>
inline std::array<batch<widen_t<T>, A>, 2> widen(batch<T, A> const &x) noexcept

  Widen batch `x` from type `T` to a type with twice as many bytes and the same sign (for integers) or from float to double.

  Parameters:

    x – batch of `T`

  Returns:

    two batches of `widen_t<T>`