avx::UChar256

class UChar256

Class representing vectorized version of unsigned char. It can hold 32 individual unsigned char variables. Provides support for arithmetic and bitwise operators. str() method returns stored data as string. Supports printing directly to stream (cout).

Public Types

using storedType = unsigned char

Type that is stored inside vector.

Public Functions

inline UChar256() noexcept
inline UChar256(const unsigned char init) noexcept
inline UChar256(const __m256i &init) noexcept
inline UChar256(const UChar256 &init) noexcept
inline explicit UChar256(const unsigned char *pSrc)

Initializes object with first 32 bytes of data stored under addr. Data does not need to be aligned to any specific boundary.

Parameters:

pSrc – Memory holding data (minimum 32 bytes).

Throws:

If – used in debug mode if pSrc is nullptr then std::invalid_argument will be thrown. Otherwise if nullptr is passed it will initialize vector with 0s.

inline UChar256(const std::string &init) noexcept

Initializes with first 32 bytes read from string. If init is less than 32 bytes long missing values will be set to 0.

Parameters:

init – String containing initial data.

inline UChar256(const std::array<unsigned char, 32> &init) noexcept
inline UChar256(std::initializer_list<unsigned char> init)
inline void load (const unsigned char *pSrc) N_THROW_REL

Loads data from memory into vector (memory should be of size of at least 32 bytes). Memory doesn’t need to be aligned to any specific boundary. If sP is nullptr this method has no effect.

Parameters:

pSrc – Pointer to memory from which to load data.

Throws:

std::invalid_argument – If in Debug mode and pSrc is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline void save(std::array<unsigned char, 32> &dest) const noexcept

Saves data to destination in memory.

Parameters:

dest – Reference to the list to which vector will be saved. Array doesn’t need to be aligned to any specific boundary.

inline void save (unsigned char *pDest) const N_THROW_REL

Saves data to destination in memory. The memory doesn’t have to be aligned to any specific boundary.

See https://en.cppreference.com/w/cpp/memory/c/aligned_alloc for more details.

Parameters:

pDest – A valid pointer to a memory of at least 32 bytes (32x unsigned char).

Throws:

std::invalid_argument – If in Debug mode and pDest is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline void saveAligned (unsigned char *pDest) const N_THROW_REL

Saves data to destination in memory. The memory must be aligned at 32-byte boundary.

See https://en.cppreference.com/w/cpp/memory/c/aligned_alloc for more details.

Parameters:

pDest – A valid pointer to a memory of at least 32 bytes (32x unsigned char).

Throws:

std::invalid_argument – If in Debug mode and pDest is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline __m256i get() const noexcept

Get the internal vector value.

Returns:

The value of __m256i vector.

inline void set(const __m256i value) noexcept

Set the internal vector value.

Parameters:

value – New value to be set.

inline unsigned char operator[](const unsigned int &index) const

Indexing operator.

Parameters:

index – Position of desired element between 0 and 31.

Throws:

std::out_of_range – If index is not within the correct range and using Debug mode. If not in Debug mode no exception will be thrown (bitwise AND ensures index stays withing bounds 0-31).

Returns:

Value of underlying element.

inline bool operator==(const UChar256 &bV) const noexcept
inline bool operator==(const char b) const noexcept
inline bool operator!=(const UChar256 &bV) const noexcept
inline bool operator!=(const char b) const noexcept
inline UChar256 operator+(const UChar256 &bV) const noexcept
inline UChar256 operator+(const unsigned char &b) const noexcept
inline UChar256 &operator+=(const UChar256 &bV) noexcept
inline UChar256 &operator+=(const unsigned char &b) noexcept
inline UChar256 operator-(const UChar256 &bV) const noexcept
inline UChar256 operator-(const unsigned char &b) const noexcept
inline UChar256 &operator-=(const UChar256 &bV) noexcept
inline UChar256 &operator-=(const unsigned char &b) noexcept
inline UChar256 operator*(const UChar256 &bV) const noexcept
inline UChar256 operator*(const char &b) const noexcept
inline UChar256 &operator*=(const UChar256 &bV) noexcept
inline UChar256 &operator*=(const char &b) noexcept
inline UChar256 operator/(const UChar256 &bV) const noexcept
inline UChar256 operator/(const unsigned char b) const noexcept
inline UChar256 operator/=(const UChar256 &bV) noexcept
inline UChar256 operator/=(const unsigned char b) noexcept
inline UChar256 operator%(const UChar256 &bV) const noexcept
inline UChar256 operator%(const unsigned char b) const noexcept
inline UChar256 operator%=(const UChar256 &bV) noexcept
inline UChar256 operator%=(const unsigned char b) noexcept
inline UChar256 operator&(const UChar256 &bV) const noexcept
inline UChar256 operator&(const unsigned char &b) const noexcept
inline UChar256 &operator&=(const UChar256 &bV) noexcept
inline UChar256 &operator&=(const unsigned char &b) noexcept
inline UChar256 operator|(const UChar256 &bV) const noexcept
inline UChar256 operator|(const unsigned char &b) const noexcept
inline UChar256 &operator|=(const UChar256 &bV) noexcept
inline UChar256 &operator|=(const unsigned char &b) noexcept
inline UChar256 operator^(const UChar256 &bV) const noexcept
inline UChar256 operator^(const unsigned char &b) const noexcept
inline UChar256 &operator^=(const UChar256 &bV) noexcept
inline UChar256 &operator^=(const unsigned char &b) noexcept
inline UChar256 operator<<(const UChar256 &bV) const noexcept
inline UChar256 operator<<(const unsigned int &b) const noexcept
inline UChar256 &operator<<=(const UChar256 &bV) noexcept
inline UChar256 &operator<<=(const unsigned int &b) noexcept
inline UChar256 operator>>(const UChar256 &bV) const noexcept
inline UChar256 operator>>(const unsigned int &b) const noexcept
inline UChar256 &operator>>=(const UChar256 &bV) noexcept
inline UChar256 &operator>>=(const unsigned int &b) noexcept
inline UChar256 operator~() const noexcept
inline std::string str() const noexcept
inline std::string toString() const noexcept

Public Static Attributes

static int size = 32

Number of individual values stored by object. This value can be used to iterate over elements.

Friends

friend std::ostream &operator<<(std::ostream &os, const UChar256 &a)