namespace
ContainersContainer 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:
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::class Array
size_t)> - 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::class BigEnumSet new in Git master
size_t size = (1 <<(sizeof(T)*8 - 6))> - Set of more than 64 enum values.
- class BitArray new in Git master
- Bit array.
-
template<class T, typename std::class EnumSet
underlying_type<T>::type fullValue = typename std:: underlying_type<T>::type(~0)> - 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::class StaticArray
size_t size_, class T> - Compile-time-sized array.
-
template<std::class StaticArrayView
size_t size_, class T> - 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::auto arrayView(T(&data)[size]) -> ArrayView<T> constexpr
size_t size, class T> - 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::auto arrayView(StaticArrayView<size, T> view) -> ArrayView<T> constexpr
size_t size, class T> - 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::auto arrayView(T&& other) -> U constexpr
remove_reference<T && >::type>::from(std:: declval<T && >()))> - 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::auto arraySize(StaticArrayView<size_, T>) -> std::
size_t size_, class T> size_t constexpr -
template<std::auto arraySize(T(&)[size_]) -> std::
size_t size_, class T> size_t constexpr - C array size.
-
template<std::auto arraySize(U(T::*)[size_]) -> std::
size_t size_, class T, class U> size_t constexpr new in Git master - C array member size.
-
template<std::auto staticArrayView(T* data) -> StaticArrayView<size, T> constexpr
size_t size, class T> - Make a static view on an array.
-
template<std::auto staticArrayView(T(&data)[size]) -> StaticArrayView<size, T> constexpr
size_t size, class T> - Make a static view on a fixed-size array.
-
template<std::auto staticArrayView(StaticArrayView<size, T> view) -> StaticArrayView<size, T> constexpr
size_t size, class T> - Make a static view on a view.
-
template<class T, class U = decltype(Implementation::ErasedStaticArrayViewConverter<typename std::auto staticArrayView(T&& other) -> U constexpr
remove_reference<T && >::type>::from(std:: declval<T && >()))> - Make a static view on an external type / from an external representation.
-
template<class U, std::auto arrayCast(StaticArrayView<size, T> view) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
size_t size, class T> - Reinterpret-cast a static array view.
-
template<class U, std::auto arrayCast(T(&data)[size]) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
size_t size, class T> - Reinterpret-cast a statically sized array.
-
template<class T, std::auto bigEnumSetDebugOutput(Utility::
size_t size> 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::auto enumCastUnderlyingType(T value) -> std::
enable_if<std:: is_enum<T>::value>::type> underlying_type<T>::type constexpr new in 2020.06 - Cast an enum to its underlying type.
-
template<class T, typename std::auto enumCastUnderlyingType(EnumSet<T, fullValue> value) -> std::
underlying_type<T>::type fullValue> underlying_type<T>::type constexpr new in 2020.06 - Cast an enum set to its underlying type.
-
template<class T, typename std::auto enumSetDebugOutput(Utility::
underlying_type<T>::type fullValue> 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::auto arrayView(StaticArray<size, T>& array) -> ArrayView<T> constexpr
size_t size, class T> - Make a view on a StaticArray.
-
template<std::auto arrayView(const StaticArray<size, T>& array) -> ArrayView<const T> constexpr
size_t size, class T> - Make a view on a const StaticArray.
-
template<std::auto staticArrayView(StaticArray<size, T>& array) -> StaticArrayView<size, T> constexpr
size_t size, class T> - Make a static view on a StaticArray.
-
template<std::auto staticArrayView(const StaticArray<size, T>& array) -> StaticArrayView<size, const T> constexpr
size_t size, class T> - Make a static view on a const StaticArray.
-
template<class U, std::auto arrayCast(StaticArray<size, T>& array) -> StaticArrayView<size*sizeof(T)/sizeof(U), U>
size_t size, class T> - Reinterpret-cast a static array.
-
template<class U, std::auto arrayCast(const StaticArray<size, T>& array) -> StaticArrayView<size*sizeof(T)/sizeof(U), const U>
size_t size, class T> -
template<std::auto arraySize(const StaticArray<size_, T>&) -> std::
size_t size_, class T> 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::auto stridedArrayView(T(&data)[size]) -> StridedArrayView1D<T> constexpr new in 2019.10
size_t size, class T> - 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::auto stridedArrayView(StaticArrayView<size, T> view) -> StridedArrayView1D<T> constexpr new in 2019.10
size_t size, class T> - 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::auto stridedArrayView(T&& other) -> U constexpr new in 2019.10
remove_reference<T && >::type>::from(std:: declval<T && >())))> - 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
#include <Corrade/Containers/StringView.h>
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
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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
#include <Corrade/Containers/BitArrayView.h>
Bit array view.
Immutable, use MutableBitArrayView for mutable access.
typedef BasicBitArrayView<char> Corrade:: Containers:: MutableBitArrayView new in Git master
#include <Corrade/Containers/BitArrayView.h>
Mutable bit array view.
#include <Corrade/Containers/StaticArray.h>
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.
#include <Corrade/Containers/StaticArray.h>
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.
#include <Corrade/Containers/StaticArray.h>
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.
#include <Corrade/Containers/StaticArray.h>
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:: MutableStridedBitArrayView = BasicStridedBitArrayView<dimensions, char> new in Git master
Mutable strided bit array view.
typedef MutableStridedBitArrayView<1> Corrade:: Containers:: MutableStridedBitArrayView1D new in Git master
One-dimensional mutable strided bit array view.
typedef MutableStridedBitArrayView<2> Corrade:: Containers:: MutableStridedBitArrayView2D new in Git master
Two-dimensional mutable strided bit array view.
typedef MutableStridedBitArrayView<3> Corrade:: Containers:: MutableStridedBitArrayView3D new in Git master
Three-dimensional mutable strided bit array view.
typedef MutableStridedBitArrayView<4> Corrade:: Containers:: MutableStridedBitArrayView4D new in Git master
Four-dimensional mutable strided bit array view.
template<unsigned dimensions>
using Corrade:: Containers:: Size = StridedDimensions<dimensions, std:: size_t> new in Git master
Multi-dimensional size for StridedArrayView.
typedef Size<1> Corrade:: Containers:: Size1D new in Git master
Size for StridedArrayView1D.
typedef Size<2> Corrade:: Containers:: Size2D new in Git master
Size for StridedArrayView2D.
typedef Size<3> Corrade:: Containers:: Size3D new in Git master
Size for StridedArrayView3D.
typedef Size<4> Corrade:: Containers:: Size4D new in Git master
Size for StridedArrayView4D.
template<unsigned dimensions>
using Corrade:: Containers:: Stride = StridedDimensions<dimensions, std:: ptrdiff_t> new in Git master
Multi-dimensional stride for StridedArrayView.
typedef Stride<1> Corrade:: Containers:: Stride1D new in Git master
Stride for StridedArrayView1D.
typedef Stride<2> Corrade:: Containers:: Stride2D new in Git master
Stride for StridedArrayView2D.
typedef Stride<3> Corrade:: Containers:: Stride3D new in Git master
Stride for StridedArrayView3D.
typedef Stride<4> Corrade:: Containers:: Stride4D new in Git master
Stride for StridedArrayView4D.
typedef EnumSet<StringViewFlag> Corrade:: Containers:: StringViewFlags new in Git master
#include <Corrade/Containers/StringView.h>
String view flags.
typedef BasicStringView<const char> Corrade:: Containers:: StringView new in Git master
#include <Corrade/Containers/StringView.h>
String view.
Immutable, use MutableStringView for mutable access.
typedef BasicStringView<char> Corrade:: Containers:: MutableStringView new in Git master
#include <Corrade/Containers/StringView.h>
Mutable string view.
typedef Corrade:: DefaultInitT Corrade:: Containers:: DefaultInitT
#include <Corrade/Tags.h>
Default initialization tag type.
typedef Corrade:: ValueInitT Corrade:: Containers:: ValueInitT
#include <Corrade/Tags.h>
Value initialization tag type.
typedef Corrade:: NoInitT Corrade:: Containers:: NoInitT
#include <Corrade/Tags.h>
No initialization tag type.
typedef Corrade:: NoCreateT Corrade:: Containers:: NoCreateT
#include <Corrade/Tags.h>
No creation tag type.
typedef Corrade:: DirectInitT Corrade:: Containers:: DirectInitT
#include <Corrade/Tags.h>
Direct initialization tag type.
typedef Corrade:: InPlaceInitT Corrade:: Containers:: InPlaceInitT
#include <Corrade/Tags.h>
In-place initialization tag type.
Function documentation
#include <Corrade/Containers/Array.h>
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::
#include <Corrade/Containers/Array.h>
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::
#include <Corrade/Containers/Array.h>
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);
#include <Corrade/Containers/Array.h>
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);
#include <Corrade/Containers/Array.h>
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.
#include <Corrade/Containers/Array.h>
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.
#include <Corrade/Containers/Array.h>
template<class T>
std:: size_t Corrade:: Containers:: arraySize(const Array<T>& view)
Array size.
See arraySize(ArrayView<T>) for more information.
#include <Corrade/Containers/ArrayView.h>
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::
std::uint32_t* data = …; Containers::ArrayView<std::uint32_t> a{data, 5}; auto b = Containers::arrayView(data, 5);
#include <Corrade/Containers/ArrayView.h>
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::
std::uint32_t data[15]; Containers::ArrayView<std::uint32_t> a{data}; auto b = Containers::arrayView(data);
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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::
Containers::StaticArrayView<15, std::uint32_t> data; Containers::ArrayView<std::uint32_t> a{data}; auto b = Containers::arrayView(data);
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
template<class T>
std:: size_t Corrade:: Containers:: arraySize(ArrayView<T> view) constexpr
Array view size.
Alias to ArrayView::
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
template<std:: size_t size_, class T>
std:: size_t Corrade:: Containers:: arraySize(T(&)[size_]) constexpr
C array size.
Equivalent to std::
int data[15]; std::size_t size = Containers::arraySize(data); // size == 15
#include <Corrade/Containers/ArrayView.h>
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_&
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
#include <Corrade/Containers/ArrayView.h>
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::
int* data = …; Containers::StaticArrayView<5, int> a{data}; auto b = Containers::staticArrayView<5>(data);
#include <Corrade/Containers/ArrayView.h>
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::
int data[15]; Containers::StaticArrayView<15, int> a{data}; auto b = Containers::staticArrayView(data);
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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.
#include <Corrade/Containers/ArrayView.h>
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);
#include <Corrade/Containers/ArrayView.h>
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
#include <Corrade/Containers/BigEnumSet.hpp>
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{};
#include <Corrade/Containers/EnumSet.h>
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.
#include <Corrade/Containers/EnumSet.h>
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.
#include <Corrade/Containers/EnumSet.hpp>
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::
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{};
#include <Corrade/Containers/Optional.h>
template<class T>
Optional<typename std:: decay<T>::type> Corrade:: Containers:: optional(T&& value)
Make an optional.
Convenience alternative to Optional::
std::string value; auto a = Containers::Optional<std::string>{value}; auto b = Containers::optional(value);
#include <Corrade/Containers/Optional.h>
template<class T, class ... Args>
Optional<T> Corrade:: Containers:: optional(Args && ... args)
Make an optional.
Convenience alternative to Optional::
auto a = Containers::Optional<std::string>{InPlaceInit, 'a', 'b'}; auto b = Containers::optional<std::string>('a', 'b');
#include <Corrade/Containers/Optional.h>
template<class T>
auto Corrade:: Containers:: optional(T&& other)
Make an optional from external representation.
#include <Corrade/Containers/Pair.h>
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::
auto a = Containers::Pair<float, int>{35.0f, 7}; auto b = Containers::pair(35.0f, 7);
#include <Corrade/Containers/Pair.h>
template<class T>
auto Corrade:: Containers:: pair(T&& other)
Make a pair from external representation.
#include <Corrade/Containers/Pointer.h>
template<class T>
Pointer<T> Corrade:: Containers:: pointer(T* pointer)
Make a unique pointer.
Convenience alternative to Pointer::
std::string* ptr = …; auto a = Containers::Pointer<std::string>{ptr}; auto b = Containers::pointer(ptr);
#include <Corrade/Containers/Pointer.h>
template<class T>
auto Corrade:: Containers:: pointer(T&& other)
Make a unique pointer from external representation.
#include <Corrade/Containers/Pointer.h>
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::static_cast<U>()
, calling Pointer::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::
#include <Corrade/Containers/Pointer.h>
template<class T, class ... Args>
Pointer<T> Corrade:: Containers:: pointer(Args && ... args)
Make a unique pointer.
Convenience alternative to Pointer::
auto a = Containers::Pointer<std::string>{InPlaceInit, 'a', 'b'}; auto b = Containers::pointer<std::string>('a', 'b');
#include <Corrade/Containers/Reference.h>
template<class T>
Reference<T> Corrade:: Containers:: reference(T& reference) constexpr new in Git master
Make a reference wrapper.
Convenience alternative to Reference::
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;
#include <Corrade/Containers/StaticArray.h>
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);
#include <Corrade/Containers/StaticArray.h>
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);
#include <Corrade/Containers/StaticArray.h>
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);
#include <Corrade/Containers/StaticArray.h>
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);
#include <Corrade/Containers/StaticArray.h>
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.
#include <Corrade/Containers/StaticArray.h>
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.
#include <Corrade/Containers/StaticArray.h>
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::
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::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::
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::
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::
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::
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::
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
#include <Corrade/Containers/StringView.h>
String view equality comparison.
bool Corrade:: Containers:: operator!=(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String view non-equality comparison.
bool Corrade:: Containers:: operator<(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String view less-than comparison.
bool Corrade:: Containers:: operator<=(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String view less-than-or-equal comparison.
bool Corrade:: Containers:: operator>=(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String view greater-than-or-equal comparison.
bool Corrade:: Containers:: operator>(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String view greater-than comparison.
String Corrade:: Containers:: operator+(StringView a,
StringView b) new in Git master
#include <Corrade/Containers/StringView.h>
String concatenation.
For joining more than one string prefer to use StringView::
String Corrade:: Containers:: operator*(StringView string,
std:: size_t count) new in Git master
#include <Corrade/Containers/StringView.h>
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
#include <Corrade/Containers/StringView.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Corrade/Containers/Triple.h>
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::
auto a = Containers::Triple<float, int, bool>{35.0f, 7, true}; auto b = Containers::triple(35.0f, 7, true);
#include <Corrade/Containers/Triple.h>
template<class T>
auto Corrade:: Containers:: triple(T&& other)
Make a triple from external representation.
#include <Corrade/Containers/GrowableArray.h>
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::
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.
#include <Corrade/Containers/GrowableArray.h>
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.
#include <Corrade/Containers/GrowableArray.h>
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.
#include <Corrade/Containers/GrowableArray.h>
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::
This function is equivalent to calling capacity() on a std::
#include <Corrade/Containers/GrowableArray.h>
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::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 in the size of the original container, 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::
#include <Corrade/Containers/GrowableArray.h>
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 in the size of the new container, 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.
#include <Corrade/Containers/GrowableArray.h>
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::
On top of what the Allocator
(or the default ArrayAllocator) itself needs, T
is required to be nothrow move-constructible and default-constructible.
#include <Corrade/Containers/GrowableArray.h>
template<class T, class Allocator = ArrayAllocator<T>>
void Corrade:: Containers:: arrayResize(Array<T>& array,
std:: size_t size) new in 2020.06
Resize an array to given size, value-initializing new elements.
Alias to arrayResize(Array<T>&, ValueInitT, std::
This function is equivalent to calling resize() on a std::
#include <Corrade/Containers/GrowableArray.h>
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::T
.
On top of what the Allocator
(or the default ArrayAllocator) itself needs, T
is required to be nothrow move-constructible.
#include <Corrade/Containers/GrowableArray.h>
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::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
.
#include <Corrade/Containers/GrowableArray.h>
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.
#include <Corrade/Containers/GrowableArray.h>
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::value
.
This function is equivalent to calling resize() on a std::
#include <Corrade/Containers/GrowableArray.h>
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::
Amortized complexity is 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_
#include <Corrade/Containers/GrowableArray.h>
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::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_
#include <Corrade/Containers/GrowableArray.h>
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
.
#include <Corrade/Containers/GrowableArray.h>
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::
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::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.
#include <Corrade/Containers/GrowableArray.h>
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.
#include <Corrade/Containers/GrowableArray.h>
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::T
.
On top of what the Allocator
(or the default ArrayAllocator) itself needs, T
is required to be nothrow move-constructible.
#include <Corrade/Containers/GrowableArray.h>
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::index
are moved one item forward, value
is copied to index
and Array::
Amortized complexity is . 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::
#include <Corrade/Containers/GrowableArray.h>
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::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::
#include <Corrade/Containers/GrowableArray.h>
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::value
.
#include <Corrade/Containers/GrowableArray.h>
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::
Amortized complexity is , where is the number of items being inserted and 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::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.
#include <Corrade/Containers/GrowableArray.h>
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.
#include <Corrade/Containers/GrowableArray.h>
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::T
.
Amortized complexity is , where 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.
#include <Corrade/Containers/GrowableArray.h>
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::index + count
are moved count
items backward and the Array::count
.
Amortized complexity is where is the number of items being removed and 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::
#include <Corrade/Containers/GrowableArray.h>
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::min(count, array.size() - index - count)
items are moved over the items at index
and the Array::count
.
Amortized complexity is where 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.
#include <Corrade/Containers/GrowableArray.h>
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::count
.
Amortized complexity is where 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_
#include <Corrade/Containers/GrowableArray.h>
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::Allocator
, it's assumed to be already as small as possible, and nothing is done.
Complexity is at most in the size of the container, 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_
#include <Corrade/Containers/GrowableArray.h>
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::Allocator
, it's assumed to be already as small as possible, and nothing is done.
Complexity is at most in the size of the container, 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
#include <Corrade/Containers/Function.h>
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
#include <Corrade/Containers/Optional.h>
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
#include <Corrade/Containers/String.h>
Allocated initialization tag.
Use for String construction that bypasses small string optimization. Small string optimization
Corrade:: DefaultInitT Corrade:: Containers:: DefaultInit constexpr
#include <Corrade/Tags.h>
Default initialization tag.
Corrade:: ValueInitT Corrade:: Containers:: ValueInit constexpr
#include <Corrade/Tags.h>
Value initialization tag.
Corrade:: NoInitT Corrade:: Containers:: NoInit constexpr
#include <Corrade/Tags.h>
No initialization tag.
Corrade:: NoCreateT Corrade:: Containers:: NoCreate constexpr
#include <Corrade/Tags.h>
No creation tag.
Corrade:: DirectInitT Corrade:: Containers:: DirectInit constexpr
#include <Corrade/Tags.h>
Direct initialization tag.
Corrade:: InPlaceInitT Corrade:: Containers:: InPlaceInit constexpr
#include <Corrade/Tags.h>
In-place initialization tag.