E.V.E  0.1-beta

◆ operator[]() [1/3]

template<typename Type , typename Cardinal >
template<typename F >
auto eve::wide< Type, Cardinal >::operator[] ( as_pattern< F >  p) const
inlinenoexcept

Static lookup via procedural lane indexing.

Generate a new eve::wide which is an arbitrary shuffling of current eve::wide lanes. ‘p’ is an instance of eve::as_pattern instantiated with a constexpr lambda that will be used to generate the pattern algorithmically. Values returned by the lambda must be between 0 and size()-1 or equal to eve::na_ to indicate the value at this lane must be replaced by zero or this operator will not participate in overload resolution.

Note that if the statically generated pattern matches a pre-defined Shuffling and Swizzling function the corresponding optimized shuffling functions will be called.

Parameters
pA eve::as_pattern_t defined from a lambda function
Returns
A wide constructed as wide{ get(p(0,size())), ..., get(p(0,size()-1)) }.
See also
eve::as_pattern

Example:

See it live on Compiler Explorer

#include <eve/wide.hpp>
#include <iostream>
int main()
{
eve::wide<int, eve::fixed<8>> r{1, 2, 4, 8, 16, 32, 64, 128};
std::cout << r << "\n";
// Reindex r with a constexpr lambda with two parameters
// i : the current index being reordered
// c : the cardinal of the value being reordered
std::cout << r[ eve::as_pattern{ [](auto i, auto c) { return c-i-1; } } ] << "\n";
}
Formula-based pattern holder.
Definition: pattern.hpp:95
Wrapper for SIMD registers.
Definition: wide.hpp:65