Corrade::Containers namespace

Container implementations.

Implementations for various containers which don't have direct equivalents in STL or are better tailored to specific use cases than general standard implementations.

This library is built if CORRADE_WITH_UTILITY is enabled when building Corrade. To use this library with CMake, request the Containers component of the Corrade package and link to the Corrade::Containers target:

find_package(Corrade REQUIRED Containers)

# ...
target_link_libraries(your-app PRIVATE Corrade::Containers)

Parts of this library are additionally available in a form of single-header libraries. See also Downloading and building Corrade and Using Corrade with CMake for more information.

Mapping between Corrade and STL containers

Since the purpose of this library is to provide alternatives to STL containers that aim to not repeat the same design mistakes and provide more flexibility in certain areas, the naming and usage doesn't necessarily match what you expect from STL. The following table shows the mapping between common STL containers and the Containers library:

Corrade typeSTL equivalent
Arraystd::vector
BitArraystd::vector<bool>
Array with custom deletersstd::unique_ptr<T[]> (no size info)
Array with overaligned memorystd::valarray
ArrayViewstd::span C++20
BitArrayView,
MutableBitArrayView
no equivalent
EnumSet,
BigEnumSet
std::bitset (no strong typing)
Functionstd::function,
std::move_only_function
Iterable,
StringIterable
no equivalent
LinkedListno equivalent
not plannedstd::list,
std::forward_list
not plannedstd::map,
std::multimap,
std::set
no equivalentstd::unordered_map,
std::unordered_multimap,
std::unordered_set
Optionalstd::optional C++17
Pairstd::pair
Pointerstd::unique_ptr
not plannedstd::shared_ptr,
std::weak_ptr
Referencestd::reference_wrapper
MoveReference,
AnyReference
no equivalent
ScopeGuardno equivalent
StaticArraystd::array
StaticArrayViewstd::span<T, size> C++20
StridedArrayViewstd::mdspan C++23
StridedBitArrayViewno equivalent
no equivalentstd::deque,
std::stack,
std::queue
Stringstd::string,
std::u8string
StringViewstd::string_view,
std::u8string_view C++17
MutableStringViewno equivalent
not plannedstd::wstring,
std::u16string,
std::u32string,
std::wstring_view,
std::u16string_view,
std::u32string_view
Triplestd::tuple<F, S, T>
no equivalentstd::any,
std::variant

Namespaces

namespace Literals new in Git master
Container literals.

Classes

struct AllocatedInitT new in Git master
Allocated initialization tag type.
template<class T>
class AnyReference new in Git master
Lightweight non-owning l-value and r-value reference wrapper.
template<class T, class D = void(*)(T*, std::size_t)>
class Array
Array.
template<class T>
struct ArrayAllocator new in 2020.06
Allocator for growable arrays.
template<class T>
struct ArrayMallocAllocator new in 2020.06
Malloc-based allocator for growable arrays.
template<class T>
struct ArrayNewAllocator new in 2020.06
New-based allocator for growable arrays.
class ArrayTuple new in Git master
Array tuple.
template<class T>
class ArrayView
Array view.
template<>
class ArrayView<const void>
Constant void array view.
template<>
class ArrayView<void> new in 2019.10
Void array view.
template<class T>
class BasicBitArrayView new in Git master
Base for bit array views.
template<unsigned dimensions, class T>
class BasicStridedBitArrayView new in Git master
Base for strided bit array views.
template<class T>
class BasicStringView new in Git master
Base for string views.
template<class T, std::size_t size = (1 <<(sizeof(T)*8 - 6))>
class BigEnumSet new in Git master
Set of more than 64 enum values.
class BitArray new in Git master
Bit array.
template<class T, typename std::underlying_type<T>::type fullValue = typename std::underlying_type<T>::type(~0)>
class EnumSet
Set of enum values.
template<class>
class Function new in Git master
Function wrapper.
template<class R, class ... Args>
class Function<R(Args...)> new in Git master
Function wrapper.
class FunctionData new in Git master
Function data storage
template<class T>
class Iterable new in Git master
Wrapper for any sequential container of values or references.
template<class T>
class IterableIterator new in Git master
Iterable iterator.
template<class T>
class LinkedList
Linked list.
template<class Derived, class List = LinkedList<Derived>>
class LinkedListItem
Item of LinkedList.
template<class T>
class MoveReference new in Git master
Lightweight non-owning r-value reference wrapper.
struct NoAllocateInitT new in Git master
No-allocate initialization tag type.
struct NullOptT
Null optional initialization tag type.
template<class T>
class Optional
Lightweight optional value.
template<class F, class S>
class Pair new in Git master
Pair of values.
template<class T>
class Pointer
Lightweight unique pointer.
template<class T>
class Reference
Lightweight non-owning reference wrapper.
class ScopeGuard
Scope guard.
template<std::size_t size_, class T>
class StaticArray
Compile-time-sized array.
template<std::size_t size_, class T>
class StaticArrayView
Compile-time-sized array view.
template<unsigned dimensions, class T>
class StridedArrayView
Multi-dimensional array view with size and stride information.
template<unsigned dimensions>
class StridedArrayView<dimensions, const void> new in 2020.06
Multi-dimensional const void array view with size and stride information.
template<unsigned dimensions>
class StridedArrayView<dimensions, void> new in 2020.06
Multi-dimensional void array view with size and stride information.
template<unsigned dimensions, class T>
class StridedDimensions new in 2019.10
Multi-dimensional size and stride for StridedArrayView and StridedBitArrayView.
template<unsigned dimensions, class T>
class StridedIterator
Strided array view iterator.
class String new in Git master
String.
class StringIterable new in Git master
Wrapper for any sequential container of strings or string views.
class StringIterableIterator new in Git master
String iterable iterator.
template<class F, class S, class T>
class Triple new in Git master
A tuple of three values.

Enums

enum class StringViewFlag: std::size_t { Global = std::size_t{1} << (sizeof(std::size_t)*8 - 1), NullTerminated = std::size_t{1} << (sizeof(std::size_t)*8 - 2) } new in Git master
String view flag.

Typedefs

template<class T>
using ArrayView2 = StaticArrayView<2, T> new in Git master
Two-component array view.
template<class T>
using ArrayView3 = StaticArrayView<3, T> new in Git master
Three-component array view.
template<class T>
using ArrayView4 = StaticArrayView<4, T> new in Git master
Four-component array view.
using BitArrayView = BasicBitArrayView<const char> new in Git master
Bit array view.
using MutableBitArrayView = BasicBitArrayView<char> new in Git master
Mutable bit array view.
template<class T>
using Array1 = StaticArray<1, T> new in Git master
One-component array.
template<class T>
using Array2 = StaticArray<2, T> new in Git master
Two-component array.
template<class T>
using Array3 = StaticArray<3, T> new in Git master
Three-component array.
template<class T>
using Array4 = StaticArray<4, T> new in Git master
Four-component array.
template<class T>
using StridedArrayView1D = StridedArrayView<1, T> new in 2019.10
One-dimensional strided array view.
template<class T>
using StridedArrayView2D = StridedArrayView<2, T> new in 2019.10
Two-dimensional strided array view.
template<class T>
using StridedArrayView3D = StridedArrayView<3, T> new in 2019.10
Three-dimensional strided array view.
template<class T>
using StridedArrayView4D = StridedArrayView<4, T> new in 2019.10
Four-dimensional strided array view.
template<unsigned dimensions>
using StridedBitArrayView = BasicStridedBitArrayView<dimensions, const char> new in Git master
Strided bit array view.
using StridedBitArrayView1D = StridedBitArrayView<1> new in Git master
One-dimensional strided bit array view.
using StridedBitArrayView2D = StridedBitArrayView<2> new in Git master
Two-dimensional strided bit array view.
using StridedBitArrayView3D = StridedBitArrayView<3> new in Git master
Three-dimensional strided bit array view.
using StridedBitArrayView4D = StridedBitArrayView<4> new in Git master
Four-dimensional strided bit array view.
template<unsigned dimensions>
using MutableStridedBitArrayView = BasicStridedBitArrayView<dimensions, char> new in Git master
Mutable strided bit array view.
using MutableStridedBitArrayView1D = MutableStridedBitArrayView<1> new in Git master
One-dimensional mutable strided bit array view.
using MutableStridedBitArrayView2D = MutableStridedBitArrayView<2> new in Git master
Two-dimensional mutable strided bit array view.
using MutableStridedBitArrayView3D = MutableStridedBitArrayView<3> new in Git master
Three-dimensional mutable strided bit array view.
using MutableStridedBitArrayView4D = MutableStridedBitArrayView<4> new in Git master
Four-dimensional mutable strided bit array view.
template<unsigned dimensions>
using Size = StridedDimensions<dimensions, std::size_t> new in Git master
Multi-dimensional size for StridedArrayView.
using Size1D = Size<1> new in Git master
Size for StridedArrayView1D.
using Size2D = Size<2> new in Git master
Size for StridedArrayView2D.
using Size3D = Size<3> new in Git master
Size for StridedArrayView3D.
using Size4D = Size<4> new in Git master
Size for StridedArrayView4D.
template<unsigned dimensions>
using Stride = StridedDimensions<dimensions, std::ptrdiff_t> new in Git master
Multi-dimensional stride for StridedArrayView.
using Stride1D = Stride<1> new in Git master
Stride for StridedArrayView1D.
using Stride2D = Stride<2> new in Git master
Stride for StridedArrayView2D.
using Stride3D = Stride<3> new in Git master
Stride for StridedArrayView3D.
using Stride4D = Stride<4> new in Git master
Stride for StridedArrayView4D.
using StringViewFlags = EnumSet<StringViewFlag> new in Git master
String view flags.
using StringView = BasicStringView<const char> new in Git master
String view.
using MutableStringView = BasicStringView<char> new in Git master
Mutable string view.
using DefaultInitT = Corrade::DefaultInitT deprecated in Git master
Default initialization tag type.
using ValueInitT = Corrade::ValueInitT deprecated in Git master
Value initialization tag type.
using NoInitT = Corrade::NoInitT deprecated in Git master
No initialization tag type.
using NoCreateT = Corrade::NoCreateT deprecated in Git master
No creation tag type.
using DirectInitT = Corrade::DirectInitT deprecated in Git master
Direct initialization tag type.
using InPlaceInitT = Corrade::InPlaceInitT deprecated in Git master
In-place initialization tag type.

Functions

template<class T>
auto array(ArrayView<const T> list) -> Array<T> new in Git master
Construct a list-initialized array.
template<class T>
auto array(std::initializer_list<T> list) -> Array<T> new in 2020.06
Construct a list-initialized array.
template<class T, class D>
auto arrayView(Array<T, D>& array) -> ArrayView<T>
Make a view on an Array.
template<class T, class D>
auto arrayView(const Array<T, D>& array) -> ArrayView<const T>
Make a view on a const Array.
template<class U, class T, class D>
auto arrayCast(Array<T, D>& array) -> ArrayView<U>
Reinterpret-cast an array.
template<class U, class T, class D>
auto arrayCast(const Array<T, D>& array) -> ArrayView<const U>
template<class T>
auto arraySize(const Array<T>& view) -> std::size_t
Array size.
template<class T>
auto arrayView(T* data, std::size_t size) -> ArrayView<T> constexpr
Make a view on an array of specific length.
template<std::size_t size, class T>
auto arrayView(T(&data)[size]) -> ArrayView<T> constexpr
Make a view on fixed-size array.
template<class T>
auto arrayView(std::initializer_list<T> list) -> ArrayView<const T> new in 2020.06
Make a view on an initializer list.
template<std::size_t size, class T>
auto arrayView(StaticArrayView<size, T> view) -> ArrayView<T> constexpr
Make a view on StaticArrayView.
template<class T>
auto arrayView(ArrayView<T> view) -> ArrayView<T> constexpr
Make a view on a view.
template<class T, class U = decltype(Implementation::ErasedArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >()))>
auto arrayView(T&& other) -> U constexpr
Make a view on an external type / from an external representation.
template<class U, class T>
auto arrayCast(ArrayView<T> view) -> ArrayView<U>
Reinterpret-cast an array view.
template<class U>
auto arrayCast(ArrayView<const void> view) -> ArrayView<U> new in 2020.06
Reinterpret-cast a void array view.
template<class T>
auto arraySize(ArrayView<T> view) -> std::size_t constexpr
Array view size.
template<std::size_t size_, class T>
auto arraySize(StaticArrayView<size_, T>) -> std::size_t constexpr
template<std::size_t size_, class T>
auto arraySize(T(&)[size_]) -> std::size_t constexpr
C array size.
template<std::size_t size_, class T, class U>
auto arraySize(U(T::*)[size_]) -> std::size_t constexpr new in Git master
C array member size.
template<std::size_t size, class T>
auto staticArrayView(T* data) -> StaticArrayView<size, T> constexpr
Make a static view on an array.
template<std::size_t size, class T>
auto staticArrayView(T(&data)[size]) -> StaticArrayView<size, T> constexpr
Make a static view on a fixed-size array.
template<std::size_t size, class T>
auto staticArrayView(StaticArrayView<size, T> view) -> StaticArrayView<size, T> constexpr
Make a static view on a view.
template<class T, class U = decltype(Implementation::ErasedStaticArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >()))>
auto staticArrayView(T&& other) -> U constexpr
Make a static view on an external type / from an external representation.
template<class U, std::size_t size, class T>
auto arrayCast(StaticArrayView<size, T> view) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
Reinterpret-cast a static array view.
template<class U, std::size_t size, class T>
auto arrayCast(T(&data)[size]) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
Reinterpret-cast a statically sized array.
template<class T, std::size_t size>
auto bigEnumSetDebugOutput(Utility::Debug& debug, BigEnumSet<T, size> value, const char* empty) -> Utility::Debug& new in Git master
Print a big enum set to debug output.
template<class T, class = typename std::enable_if<std::is_enum<T>::value>::type>
auto enumCastUnderlyingType(T value) -> std::underlying_type<T>::type constexpr new in 2020.06
Cast an enum to its underlying type.
template<class T, typename std::underlying_type<T>::type fullValue>
auto enumCastUnderlyingType(EnumSet<T, fullValue> value) -> std::underlying_type<T>::type constexpr new in 2020.06
Cast an enum set to its underlying type.
template<class T, typename std::underlying_type<T>::type fullValue>
auto enumSetDebugOutput(Utility::Debug& debug, EnumSet<T, fullValue> value, const char* empty, std::initializer_list<T> enums) -> Utility::Debug&
Print an enum set to debug output.
template<class T>
auto optional(T&& value) -> Optional<typename std::decay<T>::type>
Make an optional.
template<class T, class ... Args>
auto optional(Args && ... args) -> Optional<T>
Make an optional.
template<class T>
auto optional(T&& other) -> auto
Make an optional from external representation.
template<class F, class S>
auto pair(F&& first, S&& second) -> Pair<typename std::decay<F>::type, typename std::decay<S>::type> constexpr
Make a pair.
template<class T>
auto pair(T&& other) -> auto
Make a pair from external representation.
template<class T>
auto pointer(T* pointer) -> Pointer<T>
Make a unique pointer.
template<class T>
auto pointer(T&& other) -> auto
Make a unique pointer from external representation.
template<class U, class T>
auto pointerCast(Pointer<T>&& pointer) -> Pointer<U>
Downcast a pointer.
template<class T, class ... Args>
auto pointer(Args && ... args) -> Pointer<T>
Make a unique pointer.
template<class T>
auto reference(T& reference) -> Reference<T> constexpr new in Git master
Make a reference wrapper.
template<std::size_t size, class T>
auto arrayView(StaticArray<size, T>& array) -> ArrayView<T> constexpr
Make a view on a StaticArray.
template<std::size_t size, class T>
auto arrayView(const StaticArray<size, T>& array) -> ArrayView<const T> constexpr
Make a view on a const StaticArray.
template<std::size_t size, class T>
auto staticArrayView(StaticArray<size, T>& array) -> StaticArrayView<size, T> constexpr
Make a static view on a StaticArray.
template<std::size_t size, class T>
auto staticArrayView(const StaticArray<size, T>& array) -> StaticArrayView<size, const T> constexpr
Make a static view on a const StaticArray.
template<class U, std::size_t size, class T>
auto arrayCast(StaticArray<size, T>& array) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
Reinterpret-cast a static array.
template<class U, std::size_t size, class T>
auto arrayCast(const StaticArray<size, T>& array) -> StaticArrayView<size*sizeof(T)/sizeof(U), const U>
template<std::size_t size_, class T>
auto arraySize(const StaticArray<size_, T>&) -> std::size_t constexpr
Static array size.
template<class T>
auto stridedArrayView(ArrayView<typename StridedArrayView1D<T>::ErasedType> data, T* member, std::size_t size, std::ptrdiff_t stride) -> StridedArrayView1D<T> constexpr new in 2020.06
Make an one-dimensional strided view.
template<class T>
auto stridedArrayView(ArrayView<T> data, std::size_t size, std::ptrdiff_t stride) -> StridedArrayView1D<T> constexpr new in Git master
Make an one-dimensional strided view with explicit size and stride.
template<class T>
auto stridedArrayView(T* data, std::size_t size) -> StridedArrayView1D<T> constexpr new in Git master
Make an one-dimensional strided view on an array of specific length.
template<std::size_t size, class T>
auto stridedArrayView(T(&data)[size]) -> StridedArrayView1D<T> constexpr new in 2019.10
Make an one-dimensional strided view on a fixed-size array.
template<class T>
auto stridedArrayView(std::initializer_list<T> list) -> StridedArrayView1D<const T> new in 2020.06
Make an one-dimensional strided view on an initializer list.
template<class T>
auto stridedArrayView(ArrayView<T> view) -> StridedArrayView1D<T> constexpr new in 2019.10
Make an one-dimensional strided view on ArrayView.
template<std::size_t size, class T>
auto stridedArrayView(StaticArrayView<size, T> view) -> StridedArrayView1D<T> constexpr new in 2019.10
Make an one-dimensional strided view on StaticArrayView.
template<unsigned dimensions, class T>
auto stridedArrayView(StridedArrayView<dimensions, T> view) -> StridedArrayView<dimensions, T> constexpr new in 2019.10
Make a strided view on a strided view.
template<class T, class U = decltype(stridedArrayView(Implementation::ErasedArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >())))>
auto stridedArrayView(T&& other) -> U constexpr new in 2019.10
Make an one-dimensional strided view on an external type / from an external representation.
template<class U, unsigned dimensions, class T>
auto arrayCast(const StridedArrayView<dimensions, T>& view) -> StridedArrayView<dimensions, U>
Reinterpret-cast a strided array view.
template<class U, unsigned dimensions>
auto arrayCast(const StridedArrayView<dimensions, const void>& view) -> StridedArrayView<dimensions, U> new in 2020.06
Reinterpret-cast a void strided array view.
template<class U, unsigned dimensions>
auto arrayCast(const StridedArrayView<dimensions, void>& view) -> StridedArrayView<dimensions, U> new in 2020.06
template<unsigned newDimensions, class U, unsigned dimensions, class T>
auto arrayCast(const StridedArrayView<dimensions, T>& view) -> StridedArrayView<newDimensions, U> new in 2019.10
Reinterpret-cast and inflate or flatten a strided array view.
template<unsigned newDimensions, class U, class T>
auto arrayCast(const ArrayView<T>& view) -> StridedArrayView<newDimensions, U> new in 2020.06
Reinterpret-cast and inflate an array view.
template<unsigned newDimensions, class U, unsigned dimensions>
auto arrayCast(const StridedArrayView<dimensions, const void>& view, std::size_t lastDimensionSize) -> StridedArrayView<newDimensions, U> new in 2020.06
Reinterpret-cast and inflate a void strided array view.
template<unsigned newDimensions, class U, unsigned dimensions>
auto arrayCast(const StridedArrayView<dimensions, void>& view, std::size_t lastDimensionSize) -> StridedArrayView<newDimensions, U> new in 2020.06
auto operator==(StringView a, StringView b) -> bool new in Git master
String view equality comparison.
auto operator!=(StringView a, StringView b) -> bool new in Git master
String view non-equality comparison.
auto operator<(StringView a, StringView b) -> bool new in Git master
String view less-than comparison.
auto operator<=(StringView a, StringView b) -> bool new in Git master
String view less-than-or-equal comparison.
auto operator>=(StringView a, StringView b) -> bool new in Git master
String view greater-than-or-equal comparison.
auto operator>(StringView a, StringView b) -> bool new in Git master
String view greater-than comparison.
auto operator+(StringView a, StringView b) -> String new in Git master
String concatenation.
auto operator*(StringView string, std::size_t count) -> String new in Git master
String multiplication.
auto operator*(std::size_t count, StringView string) -> String new in Git master
template<class F, class S, class T>
auto triple(F&& first, S&& second, T&& third) -> Triple<typename std::decay<F>::type, typename std::decay<S>::type, typename std::decay<T>::type> constexpr
Make a triple.
template<class T>
auto triple(T&& other) -> auto
Make a triple from external representation.

Variables

NoAllocateInitT NoAllocateInit constexpr new in Git master
No-allocate initialization tag.
NullOptT NullOpt constexpr
Null optional initialization tag.
AllocatedInitT AllocatedInit constexpr new in Git master
Allocated initialization tag.
Corrade::DefaultInitT DefaultInit deprecated in Git master constexpr
Default initialization tag.
Corrade::ValueInitT ValueInit deprecated in Git master constexpr
Value initialization tag.
Corrade::NoInitT NoInit deprecated in Git master constexpr
No initialization tag.
Corrade::NoCreateT NoCreate deprecated in Git master constexpr
No creation tag.
Corrade::DirectInitT DirectInit deprecated in Git master constexpr
Direct initialization tag.
Corrade::InPlaceInitT InPlaceInit deprecated in Git master constexpr
In-place initialization tag.

Growable array utilities

See Growable arrays for more information.

template<class U, class T>
auto arrayAllocatorCast(Array<T>&& array) -> Array<U> new in 2020.06
Reinterpret-cast a growable array.
template<class U, template<class> class Allocator, class T>
auto arrayAllocatorCast(Array<T>&& array) -> Array<U> new in 2020.06
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayIsGrowable(Array<T>& array) -> bool new in 2020.06
Whether an array is growable.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayCapacity(Array<T>& array) -> std::size_t new in 2020.06
Array capacity.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayReserve(Array<T>& array, std::size_t capacity) -> std::size_t new in 2020.06
Reserve given capacity in an array.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayResize(Array<T>& array, Corrade::DefaultInitT, std::size_t size) new in 2020.06
Resize an array to given size, default-initializing new elements.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayResize(Array<T>& array, Corrade::ValueInitT, std::size_t size) new in 2020.06
Resize an array to given size, value-initializing new elements.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayResize(Array<T>& array, std::size_t size) new in 2020.06
Resize an array to given size, value-initializing new elements.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayResize(Array<T>& array, Corrade::NoInitT, std::size_t size) new in 2020.06
Resize an array to given size, keeping new elements uninitialized.
template<class T, class ... Args>
void arrayResize(Array<T>& array, Corrade::DirectInitT, std::size_t size, Args && ... args) new in 2020.06
Resize an array to given size, constructing new elements using provided arguments.
template<class T, class Allocator, class ... Args>
void arrayResize(Array<T>& array, Corrade::DirectInitT, std::size_t size, Args && ... args) new in 2020.06
template<class T, class Allocator = ArrayAllocator<T>>
void arrayResize(Array<T>& array, std::size_t size, const typename std::common_type<T>::type& value) new in Git master
Resize an array to given size, copy-constructing new elements using the provided value.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayAppend(Array<T>& array, const typename std::common_type<T>::type& value) -> T& new in 2020.06
Copy-append an item to an array.
template<class T, class ... Args>
auto arrayAppend(Array<T>& array, Corrade::InPlaceInitT, Args && ... args) -> T& new in 2020.06
In-place append an item to an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayAppend(Array<T>& array, typename std::common_type<T>::type&& value) -> T& new in 2020.06
Move-append an item to an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayAppend(Array<T>& array, typename std::common_type<ArrayView<const T>>::type values) -> ArrayView<T> new in 2020.06
Copy-append a list of items to an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayAppend(Array<T>& array, std::initializer_list<typename std::common_type<T>::type> values) -> ArrayView<T> new in 2020.06
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayAppend(Array<T>& array, Corrade::NoInitT, std::size_t count) -> ArrayView<T> new in 2020.06
Append given count of uninitialized values to an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayInsert(Array<T>& array, std::size_t index, const typename std::common_type<T>::type& value) -> T& new in Git master
Copy-insert an item into an array.
template<class T, class ... Args>
auto arrayInsert(Array<T>& array, std::size_t index, Corrade::InPlaceInitT, Args && ... args) -> T& new in Git master
In-place insert an item into an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayInsert(Array<T>& array, std::size_t index, typename std::common_type<T>::type&& value) -> T& new in Git master
Move-insert an item into an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayInsert(Array<T>& array, std::size_t index, typename std::common_type<ArrayView<const T>>::type values) -> ArrayView<T> new in Git master
Copy-insert a list of items into an array.
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayInsert(Array<T>& array, std::size_t index, std::initializer_list<typename std::common_type<T>::type> values) -> ArrayView<T> new in Git master
template<class T, class Allocator = ArrayAllocator<T>>
auto arrayInsert(Array<T>& array, std::size_t index, Corrade::NoInitT, std::size_t count) -> ArrayView<T> new in Git master
Insert given count of uninitialized values into an array.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayRemove(Array<T>& array, std::size_t index, std::size_t count = 1) new in Git master
Remove an element from an array.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayRemoveUnordered(Array<T>& array, std::size_t index, std::size_t count = 1) new in Git master
Remove an element from an unordered array.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayRemoveSuffix(Array<T>& array, std::size_t count = 1) new in 2020.06
Remove a suffix from an array.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayShrink(Array<T>& array, Corrade::NoInitT = Corrade::NoInit) new in 2020.06
Convert an array back to non-growable.
template<class T, class Allocator = ArrayAllocator<T>>
void arrayShrink(Array<T>& array, Corrade::DefaultInitT) new in Git master
Convert an array back to non-growable using a default initialization.

Enum documentation

enum class Corrade::Containers::StringViewFlag: std::size_t new in Git master

String view flag.

Enumerators
Global

The referenced string is global, i.e., with an unlimited lifetime. A string view with this flag set doesn't need to have a copy allocated in order to ensure it stays in scope.

NullTerminated

The referenced string is null-terminated. A string view with this flag set doesn't need to have a null-terminated copy allocated in order to pass to an API that expects only null-terminated strings.

Typedef documentation

template<class T>
using Corrade::Containers::ArrayView2 = StaticArrayView<2, T> new in Git master

Two-component array view.

Convenience alternative to StaticArrayView<2, T>. See StaticArrayView for more information.

template<class T>
using Corrade::Containers::ArrayView3 = StaticArrayView<3, T> new in Git master

Three-component array view.

Convenience alternative to StaticArrayView<3, T>. See StaticArrayView for more information.

template<class T>
using Corrade::Containers::ArrayView4 = StaticArrayView<4, T> new in Git master

Four-component array view.

Convenience alternative to StaticArrayView<4, T>. See StaticArrayView for more information.

typedef BasicBitArrayView<const char> Corrade::Containers::BitArrayView new in Git master

Bit array view.

Immutable, use MutableBitArrayView for mutable access.

typedef BasicBitArrayView<char> Corrade::Containers::MutableBitArrayView new in Git master

Mutable bit array view.

template<class T>
using Corrade::Containers::Array1 = StaticArray<1, T> new in Git master

One-component array.

Convenience alternative to StaticArray<1, T>. See StaticArray for more information. Useful in case you want to take advantage of the NoInit tag on an arbitrary type and Optional doesn't suit the use case.

template<class T>
using Corrade::Containers::Array2 = StaticArray<2, T> new in Git master

Two-component array.

Convenience alternative to StaticArray<2, T>. See StaticArray for more information.

template<class T>
using Corrade::Containers::Array3 = StaticArray<3, T> new in Git master

Three-component array.

Convenience alternative to StaticArray<3, T>. See StaticArray for more information.

template<class T>
using Corrade::Containers::Array4 = StaticArray<4, T> new in Git master

Four-component array.

Convenience alternative to StaticArray<4, T>. See StaticArray for more information.

template<class T>
using Corrade::Containers::StridedArrayView1D = StridedArrayView<1, T> new in 2019.10

One-dimensional strided array view.

Convenience alternative to StridedArrayView<1, T>. See StridedArrayView for more information.

template<class T>
using Corrade::Containers::StridedArrayView2D = StridedArrayView<2, T> new in 2019.10

Two-dimensional strided array view.

Convenience alternative to StridedArrayView<2, T>. See StridedArrayView for more information.

template<class T>
using Corrade::Containers::StridedArrayView3D = StridedArrayView<3, T> new in 2019.10

Three-dimensional strided array view.

Convenience alternative to StridedArrayView<3, T>. See StridedArrayView for more information.

template<class T>
using Corrade::Containers::StridedArrayView4D = StridedArrayView<4, T> new in 2019.10

Four-dimensional strided array view.

Convenience alternative to StridedArrayView<4, T>. See StridedArrayView for more information.

template<unsigned dimensions>
using Corrade::Containers::StridedBitArrayView = BasicStridedBitArrayView<dimensions, const char> new in Git master

Strided bit array view.

Immutable, use MutableStridedBitArrayView for mutable access.

typedef StridedBitArrayView<1> Corrade::Containers::StridedBitArrayView1D new in Git master

One-dimensional strided bit array view.

Immutable, use MutableStridedBitArrayView1D for mutable access.

typedef StridedBitArrayView<2> Corrade::Containers::StridedBitArrayView2D new in Git master

Two-dimensional strided bit array view.

Immutable, use MutableStridedBitArrayView2D for mutable access.

typedef StridedBitArrayView<3> Corrade::Containers::StridedBitArrayView3D new in Git master

Three-dimensional strided bit array view.

Immutable, use MutableStridedBitArrayView3D for mutable access.

typedef StridedBitArrayView<4> Corrade::Containers::StridedBitArrayView4D new in Git master

Four-dimensional strided bit array view.

Immutable, use MutableStridedBitArrayView4D for mutable access.

template<unsigned dimensions>
using Corrade::Containers::Size = StridedDimensions<dimensions, std::size_t> new in Git master

Multi-dimensional size for StridedArrayView.

template<unsigned dimensions>
using Corrade::Containers::Stride = StridedDimensions<dimensions, std::ptrdiff_t> new in Git master

Multi-dimensional stride for StridedArrayView.

typedef EnumSet<StringViewFlag> Corrade::Containers::StringViewFlags new in Git master

String view flags.

typedef BasicStringView<const char> Corrade::Containers::StringView new in Git master

String view.

Immutable, use MutableStringView for mutable access.

typedef BasicStringView<char> Corrade::Containers::MutableStringView new in Git master

Mutable string view.

typedef Corrade::DefaultInitT Corrade::Containers::DefaultInitT

Default initialization tag type.

typedef Corrade::ValueInitT Corrade::Containers::ValueInitT

Value initialization tag type.

typedef Corrade::NoInitT Corrade::Containers::NoInitT

No initialization tag type.

typedef Corrade::NoCreateT Corrade::Containers::NoCreateT

No creation tag type.

typedef Corrade::DirectInitT Corrade::Containers::DirectInitT

Direct initialization tag type.

typedef Corrade::InPlaceInitT Corrade::Containers::InPlaceInitT

In-place initialization tag type.

Function documentation

template<class T>
Array<T> Corrade::Containers::array(ArrayView<const T> list) new in Git master

Construct a list-initialized array.

Convenience shortcut to the Array::Array(InPlaceInitT, ArrayView<const T>) constructor. Not present as an implicit constructor in order to avoid the same usability issues as with std::vector — see the class documentation for more information.

template<class T>
Array<T> Corrade::Containers::array(std::initializer_list<T> list) new in 2020.06

Construct a list-initialized array.

Convenience shortcut to the Array::Array(InPlaceInitT, std::initializer_list<T>) constructor. Not present as an implicit constructor in order to avoid the same usability issues as with std::vector — see the class documentation for more information.

template<class T, class D>
ArrayView<T> Corrade::Containers::arrayView(Array<T, D>& array)

Make a view on an Array.

Convenience alternative to converting to an ArrayView explicitly. The following two lines are equivalent:

Containers::Array<std::uint32_t> data;

Containers::ArrayView<std::uint32_t> a{data};
auto b = Containers::arrayView(data);

template<class T, class D>
ArrayView<const T> Corrade::Containers::arrayView(const Array<T, D>& array)

Make a view on a const Array.

Convenience alternative to converting to an ArrayView explicitly. The following two lines are equivalent:

const Containers::Array<std::uint32_t> data;

Containers::ArrayView<const std::uint32_t> a{data};
auto b = Containers::arrayView(data);

template<class U, class T, class D>
ArrayView<U> Corrade::Containers::arrayCast(Array<T, D>& array)

Reinterpret-cast an array.

See arrayCast(ArrayView<T>) for more information.

template<class U, class T, class D>
ArrayView<const U> Corrade::Containers::arrayCast(const Array<T, D>& array)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::size_t Corrade::Containers::arraySize(const Array<T>& view)

Array size.

See arraySize(ArrayView<T>) for more information.

template<class T>
ArrayView<T> Corrade::Containers::arrayView(T* data, std::size_t size) constexpr

Make a view on an array of specific length.

Convenience alternative to ArrayView::ArrayView(T*, std::size_t). The following two lines are equivalent:

std::uint32_t* data = ;

Containers::ArrayView<std::uint32_t> a{data, 5};
auto b = Containers::arrayView(data, 5);

template<std::size_t size, class T>
ArrayView<T> Corrade::Containers::arrayView(T(&data)[size]) constexpr

Make a view on fixed-size array.

Convenience alternative to ArrayView::ArrayView(U(&)[size]). The following two lines are equivalent:

std::uint32_t data[15];

Containers::ArrayView<std::uint32_t> a{data};
auto b = Containers::arrayView(data);

template<class T>
ArrayView<const T> Corrade::Containers::arrayView(std::initializer_list<T> list) new in 2020.06

Make a view on an initializer list.

Not present as a constructor in order to avoid accidental dangling references with r-value initializer lists. See the class documentation for more information.

template<std::size_t size, class T>
ArrayView<T> Corrade::Containers::arrayView(StaticArrayView<size, T> view) constexpr

Make a view on StaticArrayView.

Convenience alternative to ArrayView::ArrayView(StaticArrayView<size, U>). The following two lines are equivalent:

Containers::StaticArrayView<15, std::uint32_t> data;

Containers::ArrayView<std::uint32_t> a{data};
auto b = Containers::arrayView(data);

template<class T>
ArrayView<T> Corrade::Containers::arrayView(ArrayView<T> view) constexpr

Make a view on a view.

Equivalent to the implicit ArrayView copy constructor — it shouldn't be an error to call arrayView() on itself.

template<class T, class U = decltype(Implementation::ErasedArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >()))>
U Corrade::Containers::arrayView(T&& other) constexpr

Make a view on an external type / from an external representation.

template<class U, class T>
ArrayView<U> Corrade::Containers::arrayCast(ArrayView<T> view)

Reinterpret-cast an array view.

Size of the new array is calculated as view.size()*sizeof(T)/sizeof(U). Expects that both types are standard layout and the total byte size doesn't change. Example usage:

int data[15];
auto a = Containers::arrayView(data);           // a.size() == 15
auto b = Containers::arrayCast<char>(a);        // b.size() == 60

template<class U>
ArrayView<U> Corrade::Containers::arrayCast(ArrayView<const void> view) new in 2020.06

Reinterpret-cast a void array view.

Size of the new array is calculated as view.size()/sizeof(U). Expects that the target type is standard layout and the total byte size doesn't change.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::size_t Corrade::Containers::arraySize(ArrayView<T> view) constexpr

Array view size.

Alias to ArrayView::size(). See also arraySize(T(&)[size_]) for querying size of a C array and arraySize(U(T::*)[size_]) for querying size of a C array member.

template<std::size_t size_, class T>
std::size_t Corrade::Containers::arraySize(StaticArrayView<size_, T>) constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t size_, class T>
std::size_t Corrade::Containers::arraySize(T(&)[size_]) constexpr

C array size.

Equivalent to std::size() from C++17. See also arraySize(U(T::*)[size_]) for querying size of an array member.

int data[15];

std::size_t size = Containers::arraySize(data);         // size == 15

template<std::size_t size_, class T, class U>
std::size_t Corrade::Containers::arraySize(U(T::*)[size_]) constexpr new in Git master

C array member size.

Variant of arraySize(T(&)[size_]) that works on array members. Note that you have to form a pointer to a member with & for this to work:

struct A {
    int data[13];
} a;

std::size_t size1 = Containers::arraySize(a.data);      // size1 == 13
std::size_t size2 = Containers::arraySize(&A::data);    // size1 == 13

template<std::size_t size, class T>
StaticArrayView<size, T> Corrade::Containers::staticArrayView(T* data) constexpr

Make a static view on an array.

Convenience alternative to StaticArrayView::StaticArrayView(T*). The following two lines are equivalent:

int* data = ;

Containers::StaticArrayView<5, int> a{data};
auto b = Containers::staticArrayView<5>(data);

template<std::size_t size, class T>
StaticArrayView<size, T> Corrade::Containers::staticArrayView(T(&data)[size]) constexpr

Make a static view on a fixed-size array.

Convenience alternative to StaticArrayView::StaticArrayView(U(&)[size_]). The following two lines are equivalent:

int data[15];

Containers::StaticArrayView<15, int> a{data};
auto b = Containers::staticArrayView(data);

template<std::size_t size, class T>
StaticArrayView<size, T> Corrade::Containers::staticArrayView(StaticArrayView<size, T> view) constexpr

Make a static view on a view.

Equivalent to the implicit StaticArrayView copy constructor — it shouldn't be an error to call staticArrayView() on itself.

template<class T, class U = decltype(Implementation::ErasedStaticArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >()))>
U Corrade::Containers::staticArrayView(T&& other) constexpr

Make a static view on an external type / from an external representation.

template<class U, std::size_t size, class T>
StaticArrayView<size*sizeof(T)/sizeof(U), U> Corrade::Containers::arrayCast(StaticArrayView<size, T> view)

Reinterpret-cast a static array view.

Size of the new array is calculated as view.size()*sizeof(T)/sizeof(U). Expects that both types are standard layout and the total byte size doesn't change. Example usage:

int data[15];
auto a = Containers::staticArrayView(data); // a.size() == 15
Containers::StaticArrayView<60, char> b = Containers::arrayCast<char>(a);

template<class U, std::size_t size, class T>
StaticArrayView<size*sizeof(T)/sizeof(U), U> Corrade::Containers::arrayCast(T(&data)[size])

Reinterpret-cast a statically sized array.

Calls arrayCast(StaticArrayView<size, T>) with the argument converted to StaticArrayView of the same type and size. Example usage:

int data[15];
auto a = Containers::arrayCast<char>(data); // a.size() == 60

template<class T, std::size_t size>
Utility::Debug& Corrade::Containers::bigEnumSetDebugOutput(Utility::Debug& debug, BigEnumSet<T, size> value, const char* empty) new in Git master

Print a big enum set to debug output.

Parameters
debug Debug output
value Value to be printed
empty What to print in case of an empty enum set

Compared to enumSetDebugOutput(), this function doesn't need an explicit list of known values but will instead go through all set bits and print them one by one. This also means unknown bits, if any, will be interleaved with the known ones. Example definition:

enum class Feature: std::uint8_t {
    Fast = 0,
    Cheap = 1,
    Tested = 2,
    Popular = 3
};

// already defined to print values as e.g. Feature::Fast and Features(0xab)
// for unknown values
Utility::Debug& operator<<(Utility::Debug&, Feature);

typedef Containers::BigEnumSet<Feature> Features;
CORRADE_ENUMSET_OPERATORS(Features)

Utility::Debug& operator<<(Utility::Debug& debug, Features value) {
    return Containers::bigEnumSetDebugOutput(debug, value, "Features{}");
}

The output is then as follows:

// prints Feature::Fast|Feature::Cheap
Utility::Debug{} << (Feature::Fast|Feature::Cheap);

// prints Feature::Popular|Feature(0xca)|Feature(0xfe)
Utility::Debug{} << (Feature::Popular|Feature(0xca)|Feature(0xfe));

// prints Features{}
Utility::Debug{} << Features{};

template<class T, class = typename std::enable_if<std::is_enum<T>::value>::type>
std::underlying_type<T>::type Corrade::Containers::enumCastUnderlyingType(T value) constexpr new in 2020.06

Cast an enum to its underlying type.

Works only with EnumSet, not with BigEnumSet.

template<class T, typename std::underlying_type<T>::type fullValue>
std::underlying_type<T>::type Corrade::Containers::enumCastUnderlyingType(EnumSet<T, fullValue> value) constexpr new in 2020.06

Cast an enum set to its underlying type.

Works only with EnumSet, not with BigEnumSet.

template<class T, typename std::underlying_type<T>::type fullValue>
Utility::Debug& Corrade::Containers::enumSetDebugOutput(Utility::Debug& debug, EnumSet<T, fullValue> value, const char* empty, std::initializer_list<T> enums)

Print an enum set to debug output.

Parameters
debug Debug output
value Value to be printed
empty What to print in case of an empty enum set
enums Recognized enum values

Assuming the underlying enum type has already implemented operator<< for Utility::Debug, this function is able to print the values in given enum set. Example definition:

enum class Feature: unsigned int {
    Fast = 1 << 0,
    Cheap = 1 << 1,
    Tested = 1 << 2,
    Popular = 1 << 3
};

// already defined to print values as e.g. Feature::Fast and Features(0xabcd)
// for unknown values
Utility::Debug& operator<<(Utility::Debug&, Feature);

typedef Containers::EnumSet<Feature> Features;
CORRADE_ENUMSET_OPERATORS(Features)

Utility::Debug& operator<<(Utility::Debug& debug, Features value) {
    return Containers::enumSetDebugOutput(debug, value, "Features{}", {
        Feature::Fast,
        Feature::Cheap,
        Feature::Tested,
        Feature::Popular});
}

The usage would then be straightforward:

// prints Feature::Fast|Feature::Cheap
Utility::Debug{} << (Feature::Fast|Feature::Cheap);

// prints Feature::Popular|Feature(0xdead)
Utility::Debug{} << (Feature::Popular|Feature(0xdead));

// prints Features{}
Utility::Debug{} << Features{};

template<class T>
Optional<typename std::decay<T>::type> Corrade::Containers::optional(T&& value)

Make an optional.

Convenience alternative to Optional::Optional(const T&) or Optional::Optional(T&&). The following two lines are equivalent:

std::string value;

auto a = Containers::Optional<std::string>{value};
auto b = Containers::optional(value);

template<class T, class ... Args>
Optional<T> Corrade::Containers::optional(Args && ... args)

Make an optional.

Convenience alternative to Optional::Optional(InPlaceInitT, Args&&... args). The following two lines are equivalent:

auto a = Containers::Optional<std::string>{InPlaceInit, 'a', 'b'};
auto b = Containers::optional<std::string>('a', 'b');

template<class T>
auto Corrade::Containers::optional(T&& other)

Make an optional from external representation.

template<class F, class S>
Pair<typename std::decay<F>::type, typename std::decay<S>::type> Corrade::Containers::pair(F&& first, S&& second) constexpr

Make a pair.

Convernience alternative to Pair::Pair(const F&, const S&) and overloads. The following two lines are equivalent:

auto a = Containers::Pair<float, int>{35.0f, 7};
auto b = Containers::pair(35.0f, 7);

template<class T>
auto Corrade::Containers::pair(T&& other)

Make a pair from external representation.

template<class T>
Pointer<T> Corrade::Containers::pointer(T* pointer)

Make a unique pointer.

Convenience alternative to Pointer::Pointer(T*). The following two lines are equivalent:

std::string* ptr = ;

auto a = Containers::Pointer<std::string>{ptr};
auto b = Containers::pointer(ptr);

template<class T>
auto Corrade::Containers::pointer(T&& other)

Make a unique pointer from external representation.

template<class U, class T>
Pointer<U> Corrade::Containers::pointerCast(Pointer<T>&& pointer)

Downcast a pointer.

While upcasting (derived to base) is handled implicitly with Pointer::Pointer(Pointer<U>&&), downcasting needs to be done explicitly. Performs static_cast<U>(), calling Pointer::release() on pointer. You have to ensure the pointer is actually of type U, as only the inheritance relation between T and U is checked at compile time, not the actual type stored in pointer.

Casting with dynamic_cast<U>() is not supported, as it would lead to a destructive behavior in case the instance is not of type U. The standard library provides std::dynamic_pointer_cast() and friends for this case, but they return a std::shared_ptr in order to behave non-destructively.

template<class T, class ... Args>
Pointer<T> Corrade::Containers::pointer(Args && ... args)

Make a unique pointer.

Convenience alternative to Pointer::Pointer(InPlaceInitT, Args&&... args), similar to std::make_unique() from C++14. The following two lines are equivalent:

auto a = Containers::Pointer<std::string>{InPlaceInit, 'a', 'b'};
auto b = Containers::pointer<std::string>('a', 'b');

template<class T>
Reference<T> Corrade::Containers::reference(T& reference) constexpr new in Git master

Make a reference wrapper.

Convenience alternative to Reference::Reference(T&). Thw following two lines are equivalent:

float target = ;

auto a = Containers::Reference<float>{target};
auto b = Containers::reference(target);

Useful for example when iterating a list of variables that need to be modified in-place, and where the code would otherwise have to be extra verbose or would fall back to raw pointers and risk them getting nullptr:

for(int& i: {Containers::reference(a),
             Containers::reference(b),
             Containers::reference(c)})
    i = i*i;

template<std::size_t size, class T>
ArrayView<T> Corrade::Containers::arrayView(StaticArray<size, T>& array) constexpr

Make a view on a StaticArray.

Convenience alternative to converting to an ArrayView explicitly. The following two lines are equivalent:

Containers::StaticArray<5, int> data;

Containers::ArrayView<int> a{data};
auto b = Containers::arrayView(data);

template<std::size_t size, class T>
ArrayView<const T> Corrade::Containers::arrayView(const StaticArray<size, T>& array) constexpr

Make a view on a const StaticArray.

Convenience alternative to converting to an ArrayView explicitly. The following two lines are equivalent:

const Containers::StaticArray<5, int> data;

Containers::ArrayView<const int> a{data};
auto b = Containers::arrayView(data);

template<std::size_t size, class T>
StaticArrayView<size, T> Corrade::Containers::staticArrayView(StaticArray<size, T>& array) constexpr

Make a static view on a StaticArray.

Convenience alternative to converting to an StaticArrayView explicitly. The following two lines are equivalent:

Containers::StaticArray<5, int> data;

Containers::StaticArrayView<5, int> a{data};
auto b = Containers::staticArrayView(data);

template<std::size_t size, class T>
StaticArrayView<size, const T> Corrade::Containers::staticArrayView(const StaticArray<size, T>& array) constexpr

Make a static view on a const StaticArray.

Convenience alternative to converting to an StaticArrayView explicitly. The following two lines are equivalent:

const Containers::StaticArray<5, int> data;

Containers::StaticArrayView<5, const int> a{data};
auto b = Containers::staticArrayView(data);

template<class U, std::size_t size, class T>
StaticArrayView<size*sizeof(T)/sizeof(U), U> Corrade::Containers::arrayCast(StaticArray<size, T>& array)

Reinterpret-cast a static array.

See arrayCast(StaticArrayView<size, T>) for more information.

template<class U, std::size_t size, class T>
StaticArrayView<size*sizeof(T)/sizeof(U), const U> Corrade::Containers::arrayCast(const StaticArray<size, T>& array)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t size_, class T>
std::size_t Corrade::Containers::arraySize(const StaticArray<size_, T>&) constexpr

Static array size.

See arraySize(ArrayView<T>) for more information.

template<class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(ArrayView<typename StridedArrayView1D<T>::ErasedType> data, T* member, std::size_t size, std::ptrdiff_t stride) constexpr new in 2020.06

Make an one-dimensional strided view.

Convenience alternative to StridedArrayView::StridedArrayView(ArrayView<ErasedType>, T*, const Containers::Size<dimensions>&, const Containers::Stride<dimensions>&). The following two lines are equivalent:

Containers::ArrayView<Position> data;

Containers::StridedArrayView1D<float> a{data, &data[0].x, 9, sizeof(Position)};
auto b = Containers::stridedArrayView(data, &data[0].x, 9, sizeof(Position));

See also StridedArrayView::slice() const for slicing into struct members.

template<class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(ArrayView<T> data, std::size_t size, std::ptrdiff_t stride) constexpr new in Git master

Make an one-dimensional strided view with explicit size and stride.

Convenience alternative to StridedArrayView::StridedArrayView(ArrayView<T>, const Containers::Size<dimensions>&, const Containers::Stride<dimensions>&). The following two lines are equivalent, skipping all odd items in the array:

Containers::ArrayView<float> data;

Containers::StridedArrayView1D<float> a{data, 5, 8};
auto b = Containers::stridedArrayView(data, 5, 8);

template<class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(T* data, std::size_t size) constexpr new in Git master

Make an one-dimensional strided view on an array of specific length.

Convenience alternative to StridedArrayView::StridedArrayView(T*, std::size_t). The following two lines are equivalent:

std::uint32_t* data = ;

Containers::StridedArrayView1D<std::uint32_t> a{data, 5};
auto b = Containers::stridedArrayView(data, 5);

template<std::size_t size, class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(T(&data)[size]) constexpr new in 2019.10

Make an one-dimensional strided view on a fixed-size array.

Convenience alternative to StridedArrayView::StridedArrayView(U(&)[size]). The following two lines are equivalent:

std::uint32_t data[15];

Containers::StridedArrayView1D<std::uint32_t> a{data};
auto b = Containers::stridedArrayView(data);

template<class T>
StridedArrayView1D<const T> Corrade::Containers::stridedArrayView(std::initializer_list<T> list) new in 2020.06

Make an one-dimensional strided view on an initializer list.

Not present as a constructor in order to avoid accidental dangling references with r-value initializer lists. See ArrayView documentation for more information.

template<class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(ArrayView<T> view) constexpr new in 2019.10

Make an one-dimensional strided view on ArrayView.

Convenience alternative to StridedArrayView::StridedArrayView(ArrayView<U>). The following two lines are equivalent:

Containers::ArrayView<std::uint32_t> data;

Containers::StridedArrayView1D<std::uint32_t> a{data};
auto b = Containers::stridedArrayView(data);

template<std::size_t size, class T>
StridedArrayView1D<T> Corrade::Containers::stridedArrayView(StaticArrayView<size, T> view) constexpr new in 2019.10

Make an one-dimensional strided view on StaticArrayView.

Convenience alternative to StridedArrayView::StridedArrayView(StaticArrayView<size, U>). The following two lines are equivalent:

Containers::StaticArrayView<15, std::uint32_t> data;

Containers::StridedArrayView1D<std::uint32_t> a{data};
auto b = Containers::stridedArrayView(data);

template<unsigned dimensions, class T>
StridedArrayView<dimensions, T> Corrade::Containers::stridedArrayView(StridedArrayView<dimensions, T> view) constexpr new in 2019.10

Make a strided view on a strided view.

Equivalent to the implicit StridedArrayView copy constructor — it shouldn't be an error to call stridedArrayView() on itself.

template<class T, class U = decltype(stridedArrayView(Implementation::ErasedArrayViewConverter<typename std::remove_reference<T && >::type>::from(std::declval<T && >())))>
U Corrade::Containers::stridedArrayView(T&& other) constexpr new in 2019.10

Make an one-dimensional strided view on an external type / from an external representation.

template<class U, unsigned dimensions, class T>
StridedArrayView<dimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, T>& view)

Reinterpret-cast a strided array view.

Size of the new array is the same as original. Expects that both types are standard layout and sizeof(U) is not larger than any stride() of the original array. Works with negative and zero strides as well, however note that no type compatibility checks can be done for zero strides, so be extra careful in that case. Example usage:

struct Pixel {
    std::uint8_t r, g, b, a;
};

Pixel pixels[]{{0x33, 0xff, 0x99, 0x66}, {0x11, 0xab, 0x33, 0xff}};

auto red = Containers::StridedArrayView1D<std::uint8_t>{pixels, &pixels[0].r, 2, 4};
auto rgba = Containers::arrayCast<Pixel>(red);

template<class U, unsigned dimensions>
StridedArrayView<dimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, const void>& view) new in 2020.06

Reinterpret-cast a void strided array view.

Size of the new array is the same as original. Expects that the target type is standard layout and sizeof(U) is not larger than any stride() of the original array. Works with negative and zero strides as well, however note that no type compatibility checks can be done for zero strides, so be extra careful in that case.

template<class U, unsigned dimensions>
StridedArrayView<dimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, void>& view) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<unsigned newDimensions, class U, unsigned dimensions, class T>
StridedArrayView<newDimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, T>& view) new in 2019.10

Reinterpret-cast and inflate or flatten a strided array view.

If newDimensions > dimensions, inflates the last dimension into the new type U, its element count being ratio of T and U sizes. The newDimensions template parameter is expected to always be one more than dimensions. This operation can be used for example to peek into individual channels pixel data:

struct Rgb {
    std::uint8_t r, g, b;
};

Containers::ArrayView<Rgb> pixels;

Containers::StridedArrayView2D<Rgb> view{pixels, {128, 128}};
Containers::StridedArrayView3D<std::uint8_t> rgb =
    Containers::arrayCast<3, std::uint8_t>(view);

If newDimensions < dimensions, flattens the last dimension into a contiguous new type U, expecting the last dimension to be contiguous and its stride equal to size of U. The newDimensions template parameter is expected to always be one less than dimensions.

Lastly, if newDimensions == dimensions, the last dimension is reinterpreted as U, expecting it to be contiguous and its total byte size being divisible by the size of U. The resulting last dimension has a size that's a ratio of T and U sizes and stride equivalent to U, being again contiguous.

Expects that both types are standard layout and sizeof(U) is not larger than any stride() of the original array. Works with negative and zero strides as well, however note that no type compatibility checks can be done for zero strides, so be extra careful in that case.

template<unsigned newDimensions, class U, class T>
StridedArrayView<newDimensions, U> Corrade::Containers::arrayCast(const ArrayView<T>& view) new in 2020.06

Reinterpret-cast and inflate an array view.

Converts view to a StridedArrayView1D and calls the above function.

template<unsigned newDimensions, class U, unsigned dimensions>
StridedArrayView<newDimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, const void>& view, std::size_t lastDimensionSize) new in 2020.06

Reinterpret-cast and inflate a void strided array view.

Inflates the last dimension into the new type U, its element count being lastDimensionSize. The newDimensions template parameter is expected to always be one more than dimensions. For flattening the view (inverse of this operation) you need to cast to a concrete type first.

Expects that the target type is standard layout and sizeof(U) is not larger than any stride() of the original array. Works with negative and zero strides as well, however note that no type compatibility checks can be done for zero strides, so be extra careful in that case.

template<unsigned newDimensions, class U, unsigned dimensions>
StridedArrayView<newDimensions, U> Corrade::Containers::arrayCast(const StridedArrayView<dimensions, void>& view, std::size_t lastDimensionSize) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Corrade::Containers::operator==(StringView a, StringView b) new in Git master

String view equality comparison.

bool Corrade::Containers::operator!=(StringView a, StringView b) new in Git master

String view non-equality comparison.

bool Corrade::Containers::operator<(StringView a, StringView b) new in Git master

String view less-than comparison.

bool Corrade::Containers::operator<=(StringView a, StringView b) new in Git master

String view less-than-or-equal comparison.

bool Corrade::Containers::operator>=(StringView a, StringView b) new in Git master

String view greater-than-or-equal comparison.

bool Corrade::Containers::operator>(StringView a, StringView b) new in Git master

String view greater-than comparison.

String Corrade::Containers::operator+(StringView a, StringView b) new in Git master

String concatenation.

For joining more than one string prefer to use StringView::join() to avoid needless temporary allocations.

String Corrade::Containers::operator*(StringView string, std::size_t count) new in Git master

String multiplication.

Equivalent to string multiplication in Python, returns string repeated count times.

String Corrade::Containers::operator*(std::size_t count, StringView string) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Triple<typename std::decay<F>::type, typename std::decay<S>::type, typename std::decay<T>::type> Corrade::Containers::triple(F&& first, S&& second, T&& third) constexpr

Make a triple.

Convernience alternative to Triple::Triple(const F&, const S&, const T&) and overloads. The following two lines are equivalent:

auto a = Containers::Triple<float, int, bool>{35.0f, 7, true};
auto b = Containers::triple(35.0f, 7, true);

template<class T>
auto Corrade::Containers::triple(T&& other)

Make a triple from external representation.

template<class U, class T>
Array<U> Corrade::Containers::arrayAllocatorCast(Array<T>&& array) new in 2020.06

Reinterpret-cast a growable array.

If the array is growable using ArrayMallocAllocator (which is aliased to ArrayAllocator for all trivially-copyable types), the deleter is a simple call to a typeless std::free(). This makes it possible to change the array type without having to use a different deleter, losing the growable property in the process. Example usage:

Containers::Array<char> data = ;
Containers::Array<float> floats =
    Containers::arrayAllocatorCast<float>(std::move(data));
arrayAppend(floats, 37.0f);

Equivalently to arrayCast(), the size of the new array is calculated as view.size()*sizeof(T)/sizeof(U). Expects that both types are trivially copyable and standard layout and the total byte size doesn't change.

template<class U, template<class> class Allocator, class T>
Array<U> Corrade::Containers::arrayAllocatorCast(Array<T>&& array) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class Allocator = ArrayAllocator<T>>
bool Corrade::Containers::arrayIsGrowable(Array<T>& array) new in 2020.06

Whether an array is growable.

Returns true if the array is growable and using given Allocator, false otherwise. Note that even non-growable arrays are usable with the arrayAppend(), arrayReserve(), ... family of utilities — these will reallocate the array using provided allocator if needed.

template<class T, class Allocator = ArrayAllocator<T>>
std::size_t Corrade::Containers::arrayCapacity(Array<T>& array) new in 2020.06

Array capacity.

For a growable array using given Allocator returns its capacity, otherwise returns Array::size().

This function is equivalent to calling capacity() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
std::size_t Corrade::Containers::arrayReserve(Array<T>& array, std::size_t capacity) new in 2020.06

Reserve given capacity in an array.

Returns New capacity of the array

If array capacity is already large enough, the function returns the current capacity. Otherwise the memory is reallocated to desired capacity, with the Array::size() staying the same, and capacity returned back. Note that in case the array is non-growable of sufficient size, it's kept as such, without being reallocated to a growable version.

Complexity is at most $ \mathcal{O}(n) $ in the size of the original container, $ \mathcal{O}(1) $ if the capacity is already large enough or if the reallocation can be done in-place. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and move-assignable.

This function is equivalent to calling reserve() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayResize(Array<T>& array, Corrade::DefaultInitT, std::size_t size) new in 2020.06

Resize an array to given size, default-initializing new elements.

If the array is growable and capacity is large enough, calls a destructor on elements that get cut off the end (if any, and if T is not trivially destructible, in which case nothing is done) and returns. Otherwise, the memory is reallocated to desired size. After that, new elements at the end of the array are default-initialized using placement-new (and nothing done for trivial types). Note that in case the array is non-growable of exactly the requested size, it's kept as such, without being reallocated to a growable version.

Complexity is at most $ \mathcal{O}(n) $ in the size of the new container, $ \mathcal{O}(1) $ if current container size is already exactly of given size. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and default-constructible.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayResize(Array<T>& array, Corrade::ValueInitT, std::size_t size) new in 2020.06

Resize an array to given size, value-initializing new elements.

Similar to arrayResize(Array<T>&, DefaultInitT, std::size_t) except that the new elements at the end are not default-initialized, but value-initialized (i.e., trivial types zero-initialized and default constructor called otherwise).

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and default-constructible.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayResize(Array<T>& array, Corrade::NoInitT, std::size_t size) new in 2020.06

Resize an array to given size, keeping new elements uninitialized.

Similar to arrayResize(Array<T>&, DefaultInitT, std::size_t) except that the new elements at the end are not default-initialized, but left in an uninitialized state instead. I.e., placement-new is meant to be used on all newly added elements with a non-trivially-copyable T.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible.

template<class T, class ... Args>
void Corrade::Containers::arrayResize(Array<T>& array, Corrade::DirectInitT, std::size_t size, Args && ... args) new in 2020.06

Resize an array to given size, constructing new elements using provided arguments.

Similar to arrayResize(Array<T>&, ValueInitT, std::size_t) except that the new elements at the end are constructed using placement-new with provided args.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and constructible from provided args.

template<class T, class Allocator, class ... Args>
void Corrade::Containers::arrayResize(Array<T>& array, Corrade::DirectInitT, std::size_t size, Args && ... args) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayResize(Array<T>& array, std::size_t size, const typename std::common_type<T>::type& value) new in Git master

Resize an array to given size, copy-constructing new elements using the provided value.

Calls arrayResize(Array<T>&, DirectInitT, std::size_t, Args&&... args) with value.

This function is equivalent to calling resize() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
T& Corrade::Containers::arrayAppend(Array<T>& array, const typename std::common_type<T>::type& value) new in 2020.06

Copy-append an item to an array.

Returns Reference to the newly appended item

If the array is not growable or the capacity is not large enough, the array capacity is grown first according to rules described in the grow() function of a particular allocator. Then, value is copy-constructed at the end of the array and Array::size() increased by 1.

Amortized complexity is $ \mathcal{O}(1) $ providing the allocator growth ratio is exponential. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and copy-constructible.

This function is equivalent to calling push_back() on a std::vector.

template<class T, class ... Args>
T& Corrade::Containers::arrayAppend(Array<T>& array, Corrade::InPlaceInitT, Args && ... args) new in 2020.06

In-place append an item to an array.

Returns Reference to the newly appended item

Similar to arrayAppend(Array<T>&, const typename std::common_type<T>::type&) except that the new element is constructed using placement-new with provided args.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and constructible from provided args.

This function is equivalent to calling emplace_back() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
T& Corrade::Containers::arrayAppend(Array<T>& array, typename std::common_type<T>::type&& value) new in 2020.06

Move-append an item to an array.

Returns Reference to the newly appended item

Calls arrayAppend(Array<T>&, InPlaceInitT, Args&&... args) with value.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayAppend(Array<T>& array, typename std::common_type<ArrayView<const T>>::type values) new in 2020.06

Copy-append a list of items to an array.

Returns View on the newly appended items

Like arrayAppend(Array<T>&, const typename std::common_type<T>::type&), but inserting multiple values at once.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and copy-constructible.

Compared to the single-value arrayAppend(Array<T>&, const typename std::common_type<T>::type&), this function also handles the case where values are a slice of the array itself. In particular, if the array needs to be reallocated in order to fit the new items, the values to append are then copied from the new location.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayAppend(Array<T>& array, std::initializer_list<typename std::common_type<T>::type> values) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayAppend(Array<T>& array, Corrade::NoInitT, std::size_t count) new in 2020.06

Append given count of uninitialized values to an array.

Returns View on the newly appended items

A lower-level variant of arrayAppend(Array<T>&, typename std::common_type<ArrayView<const T>>::type) where the new values are meant to be initialized in-place after, instead of being copied from a pre-existing location. The new values are always uninitialized — i.e., placement-new is meant to be used on all inserted elements with a non-trivially-copyable T.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible.

template<class T, class Allocator = ArrayAllocator<T>>
T& Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, const typename std::common_type<T>::type& value) new in Git master

Copy-insert an item into an array.

Returns Reference to the newly inserted item

Expects that index is not larger than Array::size(). If the array is not growable or the capacity is not large enough, the array capacity is grown first according to rules described in the grow() function of a particular allocator. Then, items starting at index are moved one item forward, value is copied to index and Array::size() is increased by 1.

Amortized complexity is $ \mathcal{O}(n) $ . On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible, nothrow move-assignable and copy-constructible.

This function is equivalent to calling insert() on a std::vector.

template<class T, class ... Args>
T& Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, Corrade::InPlaceInitT, Args && ... args) new in Git master

In-place insert an item into an array.

Returns Reference to the newly inserted item

Similar to arrayInsert(Array<T>&, std::size_t, const typename std::common_type<T>::type&) except that the new element is constructed using placement-new with provided args.

On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible, nothrow move-assignable and constructible from provided args.

This function is equivalent to calling emplace() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
T& Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, typename std::common_type<T>::type&& value) new in Git master

Move-insert an item into an array.

Returns Reference to the newly appended item

Calls arrayInsert(Array<T>&, std::size_t, InPlaceInitT, Args&&... args) with value.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, typename std::common_type<ArrayView<const T>>::type values) new in Git master

Copy-insert a list of items into an array.

Returns View on the newly appended items

Like arrayInsert(Array<T>&, std::size_t, const typename std::common_type<T>::type&), but inserting multiple values at once.

Amortized complexity is $ \mathcal{O}(m + n) $ , where $ m $ is the number of items being inserted and $ n $ is the existing array size. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible, nothrow move-assignable and copy-constructible.

Compared to the single-value arrayInsert(Array<T>&, std::size_t, const typename std::common_type<T>::type&), this function also handles the case where values are a slice of the array itself. In particular, if the array needs to be reallocated in order to fit the new items, the values to insert are then copied from the new location. It's however expected that the slice and index don't overlap — in that case the caller has to handle that on its own, such as by splitting the insertion in two.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, std::initializer_list<typename std::common_type<T>::type> values) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class Allocator = ArrayAllocator<T>>
ArrayView<T> Corrade::Containers::arrayInsert(Array<T>& array, std::size_t index, Corrade::NoInitT, std::size_t count) new in Git master

Insert given count of uninitialized values into an array.

Returns View on the newly appended items

A lower-level variant of arrayInsert(Array<T>&, std::size_t, typename std::common_type<ArrayView<const T>>::type) where the new values are meant to be initialized in-place after, instead of being copied from a pre-existing location. Independently of whether the array was reallocated to fit the new items or the items were just shifted around because the capacity was large enough, the new values are always uninitialized — i.e., placement-new is meant to be used on all inserted elements with a non-trivially-copyable T.

Amortized complexity is $ \mathcal{O}(n) $ , where $ n $ is the existing array size. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and nothrow move-assignable.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayRemove(Array<T>& array, std::size_t index, std::size_t count = 1) new in Git master

Remove an element from an array.

Expects that index + count is not larger than Array::size(). If the array is not growable, all elements except the removed ones are reallocated to a growable version. Otherwise, items starting at index + count are moved count items backward and the Array::size() is decreased by count.

Amortized complexity is $ \mathcal{O}(m + n) $ where $ m $ is the number of items being removed and $ n $ is the array size after removal. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and nothrow move-assignable.

This function is equivalent to calling erase() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayRemoveUnordered(Array<T>& array, std::size_t index, std::size_t count = 1) new in Git master

Remove an element from an unordered array.

A variant of arrayRemove() that is more efficient in case the order of items in the array doesn't have to be preserved. Expects that index + count is not larger than Array::size(). If the array is not growable, all elements except the removed ones are reallocated to a growable version. Otherwise, the last min(count, array.size() - index - count) items are moved over the items at index and the Array::size() is decreased by count.

Amortized complexity is $ \mathcal{O}(m) $ where $ m $ is the number of items being removed. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible and nothrow move-assignable.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayRemoveSuffix(Array<T>& array, std::size_t count = 1) new in 2020.06

Remove a suffix from an array.

Expects that count is not larger than Array::size(). If the array is not growable, all its elements except the removed suffix are reallocated to a growable version. Otherwise, a destructor is called on removed elements and the Array::size() is decreased by count.

Amortized complexity is $ \mathcal{O}(m) $ where $ m $ is the number of items removed. On top of what the Allocator (or the default ArrayAllocator) itself needs, T is required to be nothrow move-constructible.

With count set to 1, this function is equivalent to calling pop_back() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayShrink(Array<T>& array, Corrade::NoInitT = Corrade::NoInit) new in 2020.06

Convert an array back to non-growable.

Allocates a NoInit array that's exactly large enough to fit Array::size() elements, move-constructs the elements there and frees the old memory using Array::deleter(). If the array is not growable using given Allocator, it's assumed to be already as small as possible, and nothing is done.

Complexity is at most $ \mathcal{O}(n) $ in the size of the container, $ \mathcal{O}(1) $ if the array is already non-growable. No constraints on T from Allocator (or the default ArrayAllocator) apply here but T is required to be nothrow move-constructible.

This function is equivalent to calling shrink_to_fit() on a std::vector.

template<class T, class Allocator = ArrayAllocator<T>>
void Corrade::Containers::arrayShrink(Array<T>& array, Corrade::DefaultInitT) new in Git master

Convert an array back to non-growable using a default initialization.

Allocates a DefaultInit array that's exactly large enough to fit Array::size() elements, move-assigns the elements there and frees the old memory using Array::deleter(). If the array is not growable using given Allocator, it's assumed to be already as small as possible, and nothing is done.

Complexity is at most $ \mathcal{O}(n) $ in the size of the container, $ \mathcal{O}(1) $ if the array is already non-growable. No constraints on T from Allocator (or the default ArrayAllocator) apply here but T is required to be default-constructible and nothrow move-assignable.

Compared to arrayShrink(Array<T>&, NoInitT), the resulting array instance always has a default (nullptr) deleter. This is useful when it's not possible to use custom deleters, such as in plugin implementations.

Variable documentation

NoAllocateInitT Corrade::Containers::NoAllocateInit constexpr new in Git master

No-allocate initialization tag.

Used to distinguish Function construction that disallows allocating stateful function data on heap. Function call overhead

NullOptT Corrade::Containers::NullOpt constexpr

Null optional initialization tag.

Use for explicit initialization of null Optional. Checking an optional for emptiness can be done either by comparing it against this variable or by making use of its (explicit) boolean conversion.

AllocatedInitT Corrade::Containers::AllocatedInit constexpr new in Git master

Allocated initialization tag.

Use for String construction that bypasses small string optimization. Small string optimization

Corrade::DefaultInitT Corrade::Containers::DefaultInit constexpr

Default initialization tag.

Corrade::ValueInitT Corrade::Containers::ValueInit constexpr

Value initialization tag.

Corrade::NoInitT Corrade::Containers::NoInit constexpr

No initialization tag.

Corrade::NoCreateT Corrade::Containers::NoCreate constexpr

No creation tag.

Corrade::DirectInitT Corrade::Containers::DirectInit constexpr

Direct initialization tag.

Corrade::InPlaceInitT Corrade::Containers::InPlaceInit constexpr

In-place initialization tag.