template<unsigned dimensions, class T>
Corrade::Containers::BasicStridedBitArrayView class new in Git master

Base for strided bit array views.

A view over an arbitrary multi-dimensional strided range of bits, including sub-byte offsets — a bit-sized variant of a StridedArrayView. A multi-dimensional counterpart to a BitArrayView.

Usage

The class is meant to be used through either the StridedBitArrayView or MutableStridedBitArrayView typedefs and their dimension-specific variants. The class is implicitly convertible from BitArrayView instances, it's also possible to implicitly create a const view on a mutable (strided) bit array view. Besides that, a strided view can be created manually by specifying the original contiguous view, bit count and a stride between the bits:

const char data[]{0b1111, 0b1100, 0b0011, 0b0000};
Containers::BitArrayView bits{data, 0, 32};

/* 1, 0, 1, 0 */
Containers::StridedBitArrayView1D a{bits, 4, 8};

When constructing, if you don't specify the stride, the constructor assumes contiguous data and calculates the stride automatically — stride of a dimension is stride of the next dimension times next dimension size, while last dimension stride is implicitly 1 bit. This is especially useful for "reshaping" linear data as a multi-dimensional view. The following two statements are equivalent:

const std::uint8_t data[]{
    0b0000'0000,
    0b0011'1100,
    0b0011'1100,
    0b0000'0000,
};
Containers::BitArrayView bits{data, 0, 32};

/* In both views [1][3] to [2][5] is all 1s */
Containers::StridedBitArrayView2D a{bits, {4, 8}, {8, 1}};
Containers::StridedBitArrayView2D b{bits, {4, 8}};

A strided bit array view can be also sliced directly from a StridedArrayView using sliceBit(), see its documentation for an example.

Data access

Similarly to BitArrayView, only a small subset of the usual StridedArrayView access interface is provided — size(), isEmpty() and querying subviews or bits using operator[](). Setting bits is done using set(std::size_t) const, reset(std::size_t) const or set(std::size_t, bool) const, with all APIs having overloads for directly accessing individual bits in multi-dimensional views as well.

View slicing and transformation

Slicing functions match the StridedArrayView interface — slice(), sliceSize(), prefix(), suffix(), exceptPrefix() and exceptSuffix(), all operating with bit offsets and with shorthand versions operating only on the top-level dimension. The every(), transposed(), flipped(), broadcasted(), expanded() and collapsed() view transformation APIs work equivalently to their StridedArrayView counterparts.

Public types

enum (anonymous): unsigned { Dimensions = dimensions }
using ElementType = std::conditional<dimensions==1, bool, BasicStridedBitArrayView<dimensions - 1, T>>::type
Element type.
using ErasedType = std::conditional<std::is_const<T>::value, const void, void>::type
Erased type.

Constructors, destructors, conversion operators

BasicStridedBitArrayView(std::nullptr_t = nullptr) constexpr noexcept
Default constructor.
BasicStridedBitArrayView(BasicBitArrayView<T> data, ErasedType* begin, std::size_t offset, const Size<dimensions>& size, const Stride<dimensions>& stride) constexpr noexcept
Construct a view with explicit offset, size and stride.
BasicStridedBitArrayView(BasicBitArrayView<T> data, const Size<dimensions>& size, const Stride<dimensions>& stride) constexpr noexcept
Construct a view with explicit size and stride.
BasicStridedBitArrayView(BasicBitArrayView<T> data, const Size<dimensions>& size) constexpr noexcept
Construct a view with explicit size.
template<class U, class = typename std::enable_if<std::is_same<const U, T>::value>::type>
BasicStridedBitArrayView(const BasicStridedBitArrayView<dimensions, U>& mutable_) constexpr noexcept
Construct a StridedBitArrayView from a MutableStridedBitArrayView.
template<unsigned lessDimensions>
BasicStridedBitArrayView(const BasicStridedBitArrayView<lessDimensions, T>& other) noexcept
Construct from a StridedBitArrayView of smaller dimension count.
template<class U>
BasicStridedBitArrayView(BasicBitArrayView<U> view) constexpr noexcept
Construct from a BasicBitArrayView.

Public functions

auto data() const -> ErasedType* constexpr
Array data.
auto offset() const -> std::size_t constexpr
Bit offset.
auto size() const -> std::conditional<dimensions==1, std::size_t, const Size<dimensions>>::type constexpr
Array size.
auto stride() const -> std::conditional<dimensions==1, std::ptrdiff_t, const Stride<dimensions>&>::type constexpr
Array stride.
auto isEmpty() const -> StridedDimensions<dimensions, bool> constexpr
Whether the view is empty.
template<unsigned dimension = 0>
auto isContiguous() const -> bool
Whether the view is contiguous from given dimension further.
auto asContiguous() const -> BasicBitArrayView<T>
Convert the view to a contiguous one.
template<unsigned dimension>
auto asContiguous() const -> BasicStridedBitArrayView<dimension+1, T>
Convert the view to a contiguous one from given dimension further.
auto operator[](std::size_t i) const -> ElementType
Bit or sub-view at given position.
auto operator[](const Size<dimensions>& i) const -> bool
Bit at given position.
void set(std::size_t i) const
Set a bit at given position.
void set(const Size<dimensions>& i) const
Set a bit at given position.
void reset(std::size_t i) const
Reset a bit at given position.
void reset(const Size<dimensions>& i) const
Reset a bit at given position.
void set(std::size_t i, bool value) const
Set or reset a bit at given position.
void set(const Size<dimensions>& i, bool value) const
Set a bit at given position.
auto slice(std::size_t begin, std::size_t end) const -> BasicStridedBitArrayView<dimensions, T>
View slice in the first dimension.
auto slice(const Size<dimensions>& begin, const Size<dimensions>& end) const -> BasicStridedBitArrayView<dimensions, T>
View slice in all dimensions.
auto sliceSize(std::size_t begin, std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
View slice of given size in the first dimension.
auto sliceSize(const Size<dimensions>& begin, const Size<dimensions>& size) const -> BasicStridedBitArrayView<dimensions, T>
View slice of given size in all dimensions.
auto prefix(std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
View on the first size bits in the first dimension.
auto prefix(const Size<dimensions>& size) const -> BasicStridedBitArrayView<dimensions, T>
View on the first size bits in all dimensions.
auto suffix(std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
View on the last size bits in the first dimension.
auto suffix(const Size<dimensions>& size) const -> BasicStridedBitArrayView<dimensions, T>
View on the last size bits in all dimensions.
auto exceptPrefix(std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
View except the first size bits in the first dimension.
auto exceptPrefix(const Size<dimensions>& size) const -> BasicStridedBitArrayView<dimensions, T>
View except the first size bits in all dimensions.
auto exceptSuffix(std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
View except the last size bits in the first dimension.
auto exceptSuffix(const Size<dimensions>& size) const -> BasicStridedBitArrayView<dimensions, T>
View except the last size bits in all dimensions.
auto every(std::size_t skip) const -> BasicStridedBitArrayView<dimensions, T>
Pick every Nth bit.
auto every(const Size<dimensions>& skip) const -> BasicStridedBitArrayView<dimensions, T>
Pick every Nth bit.
template<unsigned dimensionA, unsigned dimensionB>
auto transposed() const -> BasicStridedBitArrayView<dimensions, T>
Transpose two dimensions.
template<unsigned dimension>
auto flipped() const -> BasicStridedBitArrayView<dimensions, T>
Flip a dimension.
template<unsigned dimension>
auto broadcasted(std::size_t size) const -> BasicStridedBitArrayView<dimensions, T>
Broadcast a dimension.
template<unsigned dimension, unsigned count>
auto expanded(const Containers::Size<count>& size) const -> BasicStridedBitArrayView<dimensions+count - 1, T>
Expand a dimension.
template<unsigned dimension, unsigned count>
auto collapsed() const -> BasicStridedBitArrayView<dimensions - count+1, T>
Collapse dimensions.

Enum documentation

template<unsigned dimensions, class T>
enum Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::(anonymous): unsigned

Enumerators
Dimensions

View dimensions

Typedef documentation

template<unsigned dimensions, class T>
typedef std::conditional<dimensions==1, bool, BasicStridedBitArrayView<dimensions - 1, T>>::type Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::ElementType

Element type.

For StridedBitArrayView1D / MutableStridedBitArrayView1D is equivalent to bool, for higher dimensions to a strided view of one dimension less. Compared to StridedArrayView::ElementType the single-dimension type is not a reference as it's not possible to address individual bits. Instead, set() / reset() has to be used to modify the values.

template<unsigned dimensions, class T>
typedef std::conditional<std::is_const<T>::value, const void, void>::type Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::ErasedType

Erased type.

Either a const void for a StridedBitArrayView or a void for a MutableStridedBitArrayView.

Function documentation

template<unsigned dimensions, class T>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(std::nullptr_t = nullptr) constexpr noexcept

Default constructor.

Creates an empty view. Copy a non-empty BitArray, BitArrayView or StridedBitArrayView onto the instance to make it useful.

template<unsigned dimensions, class T>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(BasicBitArrayView<T> data, ErasedType* begin, std::size_t offset, const Size<dimensions>& size, const Stride<dimensions>& stride) constexpr noexcept

Construct a view with explicit offset, size and stride.

Parameters
data Continuous view on the data
begin Pointer to the first byte of the strided view
offset Offset of the first bit in begin
size Bit count
stride Data stride in bits

The data view is used only for a bounds check — expects that it's large enough to fit offset, size and stride in the largest dimension if the stride is either positive or negative. Zero strides unfortunately can't be reliably checked for out-of-bounds conditions, so be extra careful when specifying these. The offset is expected to be less than 8 and not less than offset in data if begin is equal to data.data(); size in each dimension has to fit into 29 bits on 32-bit platforms and 61 bits on 64-bit platforms.

template<unsigned dimensions, class T>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(BasicBitArrayView<T> data, const Size<dimensions>& size, const Stride<dimensions>& stride) constexpr noexcept

Construct a view with explicit size and stride.

Equivalent to calling BasicStridedBitArrayView(BasicBitArrayView<T>, ErasedType*, std::size_t, const Size<dimensions>&, const Stride<dimensions>&) with data.data() as begin and data.offset() as offset.

template<unsigned dimensions, class T>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(BasicBitArrayView<T> data, const Size<dimensions>& size) constexpr noexcept

Construct a view with explicit size.

Assuming data is contiguous, stride is calculated implicitly from size — stride of a dimension is stride of the next dimension times next dimension size, while last dimension stride is implicitly 1 bit. In a one-dimensional case you probably want to use BasicStridedBitArrayView(BasicBitArrayView<U>) instead.

template<unsigned dimensions, class T> template<unsigned lessDimensions>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(const BasicStridedBitArrayView<lessDimensions, T>& other) noexcept

Construct from a StridedBitArrayView of smaller dimension count.

The extra dimensions are added at the front, with sizes being 1 and strides equal to size times stride of other in the first dimension. For example, a 1D view that represents an image row (the X axis) expanded to a 3D view would have 1 row (the Y axis) and 1 slice (the Z axis), in the common Z-Y-X order, with the last dimension being the most dense or even contiguous.

To reduce dimension count you can use operator[](), potentially in combination with transposed().

template<unsigned dimensions, class T> template<class U>
Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::BasicStridedBitArrayView(BasicBitArrayView<U> view) constexpr noexcept

Construct from a BasicBitArrayView.

Enabled only on one-dimensional views, in case of a MutableStridedBitArrayView only if view is also mutable. Stride is implicitly set to 1 bit.

template<unsigned dimensions, class T>
std::size_t Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::offset() const constexpr

Bit offset.

Added to the pointer returned by data() to get location of the first bit. The returned value is always less than 8 and is non-zero if the view was originally constructed with a non-zero offset or if it's a result of slicing that wasn't on a byte boundary.

template<unsigned dimensions, class T>
std::conditional<dimensions==1, std::size_t, const Size<dimensions>>::type Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::size() const constexpr

Array size.

Returns just std::size_t instead of Size for the one-dimensional case so the usual numeric operations work as expected. Explicitly cast to Size to ensure consistent behavior for all dimensions in generic implementations.

Compared to StridedArrayView::size() returns by value and not via const&, as internally the size is stored together with offset().

template<unsigned dimensions, class T>
std::conditional<dimensions==1, std::ptrdiff_t, const Stride<dimensions>&>::type Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::stride() const constexpr

Array stride.

Returns just std::ptrdiff_t instead of Stride for the one-dimensional case so the usual numeric operations work as expected. Explicitly cast to Stride to ensure consistent behavior for all dimensions in generic implementations.

template<unsigned dimensions, class T>
StridedDimensions<dimensions, bool> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::isEmpty() const constexpr

Whether the view is empty.

template<unsigned dimensions, class T> template<unsigned dimension = 0>
bool Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::isContiguous() const

Whether the view is contiguous from given dimension further.

The view is considered contiguous if its last dimension has stride() equal to the type size and every dimension before that until and including dimension has its stride equal to element count times stride of the dimension that follows it.

Note that even if the data are tightly packed in memory, this function may return false — for example, a contiguous view with two dimensions transposed() is no longer contiguous, same as with zero or negative strides.

template<unsigned dimensions, class T>
BasicBitArrayView<T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::asContiguous() const

Convert the view to a contiguous one.

Returns a view large as the product of sizes in all dimensions. Expects that the view is contiguous.

template<unsigned dimensions, class T> template<unsigned dimension>
BasicStridedBitArrayView<dimension+1, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::asContiguous() const

Convert the view to a contiguous one from given dimension further.

Returns a view with the last dimension having size as the product of sizes in this and all following dimensions, and stride equal to sizeof(T). Expects that isContiguous<dimension>() returns true.

Assuming the view is contiguous, calling this function with dimension equal to Dimensions minus one will return the same view; calling it with 0 will return a StridedBitArrayView1D with stride of 1 bit; while the non-templated asContiguous() will return a BitArrayView (where the stride is implicitly defined as 1 bit).

template<unsigned dimensions, class T>
ElementType Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::operator[](std::size_t i) const

Bit or sub-view at given position.

Expects that i is less than size(). On multi-dimensional views returns a view of one dimension less, use operator[](const Containers::Size<dimensions>&) const to index all dimensions. Setting bit values is only possible on mutable views with set(std::size_t) const, reset(std::size_t) const or set(std::size_t, bool) const.

template<unsigned dimensions, class T>
bool Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::operator[](const Size<dimensions>& i) const

Bit at given position.

Expects that i is less than size(). Setting bit values is only possible on mutable views with set(const Size<dimensions>&) const, reset(const Size<dimensions>&) const or set(const Size<dimensions>&, bool) const.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::set(std::size_t i) const

Set a bit at given position.

Expects that i is less than size(). Enabled only on a single-dimensional MutableStridedBitArrayView, use set(const Size<dimensions>&) const to set a bit in a multi-dimensional view.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::set(const Size<dimensions>& i) const

Set a bit at given position.

Expects that i is less than size(). Enabled only on a MutableStridedBitArrayView.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::reset(std::size_t i) const

Reset a bit at given position.

Expects that i is less than size(). Enabled only on a single-dimensional MutableStridedBitArrayView, use reset(const Size<dimensions>&) const to sreet a bit in a multi-dimensional view.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::reset(const Size<dimensions>& i) const

Reset a bit at given position.

Expects that i is less than size(). Enabled only on a MutableStridedBitArrayView.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::set(std::size_t i, bool value) const

Set or reset a bit at given position.

Expects that i is less than size(). Enabled only on a single-dimensional MutableStridedBitArrayView, use set(const Size<dimensions>&, bool) const to set or reset a bit in a multi-dimensional view. For a value known at compile time, explicitly calling either set(std::size_t) const or reset(std::size_t) const is a simpler operation.

template<unsigned dimensions, class T>
void Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::set(const Size<dimensions>& i, bool value) const

Set a bit at given position.

Expects that i is less than size(). Enabled only on a MutableStridedBitArrayView. For a value known at compile time, explicitly calling either set(const Size<dimensions>&) const or reset(const Size<dimensions>&) const is a simpler operation.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::slice(std::size_t begin, std::size_t end) const

View slice in the first dimension.

Both arguments are expected to be in range. On multi-dimensional views slices just the top-level dimension, use slice(const Size<dimensions>&, const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::slice(const Size<dimensions>& begin, const Size<dimensions>& end) const

View slice in all dimensions.

Values in both arguments are expected to be in range for given dimension.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::sliceSize(std::size_t begin, std::size_t size) const

View slice of given size in the first dimension.

Equivalent to data.slice(begin, begin + size). On multi-dimensional views slices just the top-level dimension, use sliceSize(const Size<dimensions>&, const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::sliceSize(const Size<dimensions>& begin, const Size<dimensions>& size) const

View slice of given size in all dimensions.

Equivalent to data.slice(begin, end), where end is begin[i] + size[i] for all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::prefix(std::size_t size) const

View on the first size bits in the first dimension.

Equivalent to data.slice(0, size). On multi-dimensional views slices just the top-level dimension, use prefix(const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::prefix(const Size<dimensions>& size) const

View on the first size bits in all dimensions.

Equivalent to data.slice({}, size).

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::suffix(std::size_t size) const

View on the last size bits in the first dimension.

Equivalent to data.slice(data.size()[0] - size, data.size()[0]). On multi-dimensional views slices just the top-level dimension, use suffix(const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::suffix(const Size<dimensions>& size) const

View on the last size bits in all dimensions.

Equivalent to data.slice(end, data.size()), where end is data.size()[i] - size[i] for all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::exceptPrefix(std::size_t size) const

View except the first size bits in the first dimension.

Equivalent to data.slice(size, data.size()[0]). On multi-dimensional views slices just the top-level dimension, use exceptPrefix(const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::exceptPrefix(const Size<dimensions>& size) const

View except the first size bits in all dimensions.

Equivalent to data.slice(size, data.size()).

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::exceptSuffix(std::size_t size) const

View except the last size bits in the first dimension.

Equivalent to data.slice({}, data.size()[0] - size). On multi-dimensional views slices just the top-level dimension, use exceptSuffix(const Size<dimensions>&) const to slice in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::exceptSuffix(const Size<dimensions>& size) const

View except the last size bits in all dimensions.

Equivalent to data.slice({}, end), where end is data.size()[i] - size[i] for all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::every(std::size_t skip) const

Pick every Nth bit.

Multiplies stride() with skip and adjusts size() accordingly. On multi-dimensional views affects just the top-level dimension, use every(const Size<dimensions>&) const to pick in all dimensions.

template<unsigned dimensions, class T>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::every(const Size<dimensions>& skip) const

Pick every Nth bit.

Multiplies stride() with skip and adjusts size() accordingly.

template<unsigned dimensions, class T> template<unsigned dimensionA, unsigned dimensionB>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::transposed() const

Transpose two dimensions.

Exchanges dimensions dimensionA and dimensionB by swapping their size and stride values. Together with flipped() can be used to do arbitrary 90° rotations of the view. This is a non-destructive operation on the view, transposing it again will go back to the original form.

template<unsigned dimensions, class T> template<unsigned dimension>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::flipped() const

Flip a dimension.

Flips given dimension by making its stride negative and adjusting the internal base data pointer. Together with transposed() can be used to do arbitrary 90° rotations of the view. This is a non-destructive operation on the view, flipping it again will go back to the original form.

template<unsigned dimensions, class T> template<unsigned dimension>
BasicStridedBitArrayView<dimensions, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::broadcasted(std::size_t size) const

Broadcast a dimension.

Stretches the initial value to size in given dimension by setting its stride to 0 and size to size. To avoid destructive operations on the view, the function expects that size in given dimension is 1. If you need to broadcast a dimension that has more than one bit, slice() it first.

template<unsigned dimensions, class T> template<unsigned dimension, unsigned count>
BasicStridedBitArrayView<dimensions+count - 1, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::expanded(const Containers::Size<count>& size) const

Expand a dimension.

Expands given dimension into multiple. The product of size is expected to be equal to size in the original dimension. The resulting view has sizes and strides before dimension unchanged, after that count - 1 new dimensions gets inserted, where each has size from size and stride equal to size times stride of the next dimension, then a dimension with size equal to last element of size and its original stride, and after that all other dimensions with sizes and strides unchanged again.

See collapsed() for an inverse of this operation.

template<unsigned dimensions, class T> template<unsigned dimension, unsigned count>
BasicStridedBitArrayView<dimensions - count+1, T> Corrade::Containers::BasicStridedBitArrayView<dimensions, T>::collapsed() const

Collapse dimensions.

Assuming dimensions from dimension up to dimension + count - 1 all have strides equal to size times stride of the next dimension, returns a view that has them all collapsed into one with its size equal to a product of sizes of these dimensions and stride equal to stride of the last dimension in this range.

See expanded() for an inverse of this operation and asContiguous() for a variant that collapses all dimensions from given index, requiring the stride of last one to be equal to the type size.

template<unsigned dimensions, class T> template<unsigned dimensions>
Utility::Debug& operator<<(Utility::Debug& debug, const StridedBitArrayView<dimensions>& value) new in Git master

Debug output operator.

Prints the value as nested {a, b, …}, with each element in the last dimension being the next 8 bits (or less, if the last dimension is smaller). To have a monotonic order, the first character in each element is the first bit in the 8-bit group — i.e., the order is reversed compared to binary literals.

For example, expanding upon the snippet in operator<<(Utility::Debug&, BitArrayView), the following 64-bit number, shifted by 5 bits and grouped into 3 rows containing 8 bits each, will print like this on a Little-Endian machine:

const std::uint64_t data[]{0b0101'0101'0011'0011'0000'1111 << 5};
Containers::BitArrayView a{data, 5, 24};
Utility::Debug{} << Containers::StridedBitArrayView2D{a, {3, 8}};

{{11110000}, {11001100}, {10101010}}

template<unsigned dimensions, class T> template<unsigned dimensions>
Utility::Debug& operator<<(Utility::Debug& debug, const MutableStridedBitArrayView<dimensions>& value) new in Git master

Debug output operator.