template<typename T>
spice::color_view class

Wrapper around color data of arbitrary length with arbitrary stride between channel samples.

Template parameters
T

Public types

using value_type = T
Alias for the type used to represent individual pixel values.

Constructors, destructors, conversion operators

color_view() constexpr
Construct a new, empty color_view object.
color_view(color_view const& other) defaulted constexpr
Create a copy of the given color_view object.
color_view(color_view&& other) defaulted constexpr
Move the the given color_view object.
color_view(T*const data, size_t stride, size_t channels) constexpr
Construct a new color_view object referring to the given data.

Public functions

auto operator=(color_view const& other) -> color_view& defaulted noexcept
Copy-assigns another color_view.
auto operator=(color_view&& other) -> color_view& defaulted noexcept
Move-assigns another color_view.
auto operator=(T const& value) -> color_view& noexcept
Assign each channel the provided value.
void reset()
Replaces the reference with a nullptr reference and resets the stride and size to 0.
void reset(color_view const& other)
Replaces the reference with the reference held by other and adjusts the size accordingly.
void reset(T*const data, size_t stride, size_t channels)
Replaces the reference to refer to data and updates the stride and channel count.
auto size() const -> size_t constexpr
Returns the channel count.
auto channels() const -> size_t constexpr
Returns the channel count.
auto stride() const -> size_t constexpr
Returns the stride.
auto data() -> T*const constexpr
Returns the data pointer.
auto data() const -> T const *const constexpr
Returns the data pointer.
auto operator[](size_t index) -> T&
Retrieve a reference to an element of the color_view.
auto operator[](size_t index) const -> T const &
Retrieve a constant reference to an element of the color_view.
auto operator+=(color_view const& rhs) -> color_view&
Add rhs to this color_view channel-wise.
auto operator+=(T const& rhs) -> color_view&
Add rhs to this color_view channel-wise.
auto operator-=(color_view const& rhs) -> color_view&
Subtract rhs from this color_view channel-wise.
auto operator-=(T const& rhs) -> color_view&
Subtract rhs from this color_view channel-wise.
auto operator*=(color_view const& rhs) -> color_view&
Multiply this color_view with rhs channel-wise.
auto operator*=(T const& rhs) -> color_view&
Multiply this color_view with rhs channel-wise.
auto operator/=(color_view const& rhs) -> color_view&
Divide this color_view by rhs channel-wise.
auto operator/=(T const& rhs) -> color_view&
Divide this color_view by rhs channel-wise.

Friends

template<typename T_other>
auto operator==(T_other const& lhs, color_view const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
Compares a color_view component-wise with a scalar.
template<typename T_other>
auto operator==(color_view const& lhs, T_other const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
Compares a color_view component-wise with a scalar.
template<typename T_other>
auto operator!=(T_other const& lhs, color_view const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
Compares a color_view component-wise with a scalar for inequality.
template<typename T_other>
auto operator!=(color_view const& lhs, T_other const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
Compares a color_view component-wise with a scalar for inequality.
auto operator==(color_view const& lhs, color_view const& rhs) -> bool
Compares two color_views for equality.
auto operator!=(color_view const& lhs, color_view const& rhs) -> bool
Compares two color_views for inequality.
template<typename T_other>
auto operator==(T_other const& lhs, color_view const& rhs) -> std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool>
Compares two color_views.
template<typename T_other>
auto operator!=(color_view const& lhs, T_other const& rhs) -> std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool>
Compares two color_views for inequality.
template<typename T_other>
auto operator==(color_view const& lhs, T_other const& rhs) -> std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool>
Compares two color_views.
template<typename T_other>
auto operator!=(T_other const& lhs, color_view const& rhs) -> std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool>
Compares two color_views for inequality.
auto operator+(color_view lhs, color_view const& rhs) -> color_view
Add rhs to lhs channel-wise.
auto operator+(color_view lhs, T const& rhs) -> color_view
Add rhs to lhs channel-wise.
auto operator-(color_view lhs, color_view const& rhs) -> color_view
Subtract rhs from lhs channel-wise.
auto operator-(color_view lhs, T const& rhs) -> color_view
Subtract rhs from lhs channel-wise.
auto operator*(color_view lhs, color_view const& rhs) -> color_view
Multiply lhs with rhs channel-wise.
auto operator*(color_view lhs, T const& rhs) -> color_view
Multiply lhs with rhs channel-wise.
auto operator/(color_view lhs, color_view const& rhs) -> color_view
Divide lhs by rhs channel-wise.
auto operator/(color_view lhs, T const& rhs) -> color_view
Divide lhs by rhs channel-wise.

Function documentation

template<typename T>
spice::color_view<T>::color_view() constexpr

Construct a new, empty color_view object.

Before the color_view can be used, it has to be assigned a reference with color_view<T>::reset.

template<typename T>
spice::color_view<T>::color_view(color_view const& other) defaulted constexpr

Create a copy of the given color_view object.

Parameters
other The color_view to copy

template<typename T>
spice::color_view<T>::color_view(color_view&& other) defaulted constexpr

Move the the given color_view object.

Parameters
other The color_view to copy

template<typename T>
spice::color_view<T>::color_view(T*const data, size_t stride, size_t channels) constexpr

Construct a new color_view object referring to the given data.

Parameters
data
stride The distance between the channels
channels The number of channels this color_view refers to

template<typename T>
color_view& spice::color_view<T>::operator=(color_view const& other) defaulted noexcept

Copy-assigns another color_view.

Parameters
other
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator=(color_view&& other) defaulted noexcept

Move-assigns another color_view.

Parameters
other
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator=(T const& value) noexcept

Assign each channel the provided value.

Parameters
value
Returns color_view&

template<typename T>
void spice::color_view<T>::reset(color_view const& other)

Replaces the reference with the reference held by other and adjusts the size accordingly.

Parameters
other

template<typename T>
size_t spice::color_view<T>::size() const constexpr

Returns the channel count.

Returns size_t

template<typename T>
size_t spice::color_view<T>::channels() const constexpr

Returns the channel count.

Returns size_t

template<typename T>
size_t spice::color_view<T>::stride() const constexpr

Returns the stride.

Returns size_t

template<typename T>
T*const spice::color_view<T>::data() constexpr

Returns the data pointer.

Returns size_t

template<typename T>
T const *const spice::color_view<T>::data() const constexpr

Returns the data pointer.

Returns size_t

template<typename T>
T& spice::color_view<T>::operator[](size_t index)

Retrieve a reference to an element of the color_view.

Parameters
index
Returns T&

template<typename T>
T const & spice::color_view<T>::operator[](size_t index) const

Retrieve a constant reference to an element of the color_view.

Parameters
index
Returns T&

template<typename T>
color_view& spice::color_view<T>::operator+=(color_view const& rhs)

Add rhs to this color_view channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator+=(T const& rhs)

Add rhs to this color_view channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator-=(color_view const& rhs)

Subtract rhs from this color_view channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator-=(T const& rhs)

Subtract rhs from this color_view channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator*=(color_view const& rhs)

Multiply this color_view with rhs channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator*=(T const& rhs)

Multiply this color_view with rhs channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator/=(color_view const& rhs)

Divide this color_view by rhs channel-wise.

Parameters
rhs
Returns color_view&

template<typename T>
color_view& spice::color_view<T>::operator/=(T const& rhs)

Divide this color_view by rhs channel-wise.

Parameters
rhs
Returns color_view&

template<typename T> template<typename T_other>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator==(T_other const& lhs, color_view const& rhs)

Compares a color_view component-wise with a scalar.

Template parameters
T_other A scalar that is comparable to the color_view's data type T
Parameters
lhs
rhs
Returns true if all elements of the color_view correspond to the scalar value, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator==(color_view const& lhs, T_other const& rhs)

Compares a color_view component-wise with a scalar.

Template parameters
T_other A scalar that is comparable to the color_view's data type T
Parameters
lhs
rhs
Returns true if all elements of the color_view correspond to the scalar value, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator!=(T_other const& lhs, color_view const& rhs)

Compares a color_view component-wise with a scalar for inequality.

Template parameters
T_other A scalar that is comparable to the color_view's data type T
Parameters
lhs
rhs
Returns true if any of the elements of the color_view do not correspond to the scalar value, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator!=(color_view const& lhs, T_other const& rhs)

Compares a color_view component-wise with a scalar for inequality.

Template parameters
T_other A scalar that is comparable to the color_view's data type T
Parameters
lhs
rhs
Returns true if any of the elements of the color_view do not correspond to the scalar value, false otherwise

template<typename T>
bool operator==(color_view const& lhs, color_view const& rhs)

Compares two color_views for equality.

Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T>
bool operator!=(color_view const& lhs, color_view const& rhs)

Compares two color_views for inequality.

Parameters
lhs
rhs
Returns true if the two do not have the same number of elements or any of the values do not correspond, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool> operator==(T_other const& lhs, color_view const& rhs)

Compares two color_views.

Template parameters
T_other A type implementing the subscript operator as well as a size member function
Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool> operator!=(color_view const& lhs, T_other const& rhs)

Compares two color_views for inequality.

Parameters
lhs
rhs
Returns true if the two do not have the same number of elements or any of the values do not correspond, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool> operator==(color_view const& lhs, T_other const& rhs)

Compares two color_views.

Template parameters
T_other A type implementing the subscript operator as well as a size member function
Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T> template<typename T_other>
std::enable_if_t<!std::is_same<color_view, T_other>::value && !std::is_scalar<T_other>::value, bool> operator!=(T_other const& lhs, color_view const& rhs)

Compares two color_views for inequality.

Parameters
lhs
rhs
Returns true if the two do not have the same number of elements or any of the values do not correspond, false otherwise

template<typename T>
color_view operator+(color_view lhs, color_view const& rhs)

Add rhs to lhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator+(color_view lhs, T const& rhs)

Add rhs to lhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator-(color_view lhs, color_view const& rhs)

Subtract rhs from lhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator-(color_view lhs, T const& rhs)

Subtract rhs from lhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator*(color_view lhs, color_view const& rhs)

Multiply lhs with rhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator*(color_view lhs, T const& rhs)

Multiply lhs with rhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator/(color_view lhs, color_view const& rhs)

Divide lhs by rhs channel-wise.

Parameters
lhs
rhs
Returns color_view&

template<typename T>
color_view operator/(color_view lhs, T const& rhs)

Divide lhs by rhs channel-wise.

Parameters
lhs
rhs
Returns color_view&