class SliceMut
Declaration
template <class T>
class SliceMut { /* full declaration omitted */ };
Description
A dynamically-sized mutable view into a contiguous sequence of objects of type `T`. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors, where there are [`sus::mem::size_of <T >()`]($sus::mem::size_of) many bytes between the start of each element. Slices are a view into a block of memory represented as a pointer and a length. A `SliceMut <T >` can be implicitly converted to a `Slice <T >`.
Declared at: sus/collections/slice.h:300
Templates
- T
Member Variables
- public Slice<T> slice_
- public static const bool SusUnsafeTrivialRelocate = ::sus::mem::TriviallyRelocatable<decltype(slice_)>
Method Overview
- public constexpr SliceMut<T>(::sus::marker::EmptyMarker)
- public SliceMut<T>()
- public constexpr Slice<T> as_slice() const & noexcept
- public void drop_iterator_invalidation_tracking(::sus::marker::UnsafeFnMarker)
- public static constexpr SliceMut<T> from_raw_collection_mut(::sus::marker::UnsafeFnMarker, ::sus::iter::IterRefCounter refs, T * data, sus::num::usize len) noexcept
- public static constexpr SliceMut<T> from_raw_parts_mut(::sus::marker::UnsafeFnMarker, T * data, sus::num::usize len) noexcept
- public constexpr Slice<T> operator Slice<type-parameter-0-0>() && noexcept
- public constexpr Slice<T> & operator Slice<type-parameter-0-0> &() & noexcept
- public constexpr const Slice<T> & operator const Slice<type-parameter-0-0> &() const & noexcept
Methods
¶constexpr SliceMut<T>(::sus::marker::EmptyMarker)
constexpr SliceMut<T>(::sus::marker::EmptyMarker)
Description
Constructs an empty `Slice`. This constructor is implicit so that using the [`EmptyMarker`]( $sus::marker::EmptyMarker) allows the caller to avoid spelling out the full `Slice` type. #[doc.overloads=empty]
Declared at: sus/collections/slice.h:316
Parameters
¶SliceMut<T>()
SliceMut<T>()
Description
Constructs an empty SliceMut, which has no elements.
Declared at: sus/collections/slice.h:319
¶constexpr Slice<T> as_slice() const& noexcept
constexpr Slice<T> as_slice() const& noexcept
Declared at: sus/collections/slice.h:444
¶void drop_iterator_invalidation_tracking(
::sus::marker::UnsafeFnMarker)
void drop_iterator_invalidation_tracking(
::sus::marker::UnsafeFnMarker)
Description
Stops tracking iterator invalidation. # Safety If the Slice points into a collection and that collection is invalidated, it will no longer be caught. The caller must provide conditions that can ensure the `SliceMut`'s pointer into the collection will remain valid. Iterator invalidation tracking also tracks the stability of the collection object itself, not just its contents, which can be overly strict. This function can be used when the collection's contents will remain valid, but the collection itself may be moved, which would invalidate the tracking and be treated as invalidating the iterator. There is no way to restore tracking.
Declared at: sus/collections/slice.h:470
Parameters
¶static constexpr SliceMut<T>
from_raw_collection_mut(
::sus::marker::UnsafeFnMarker,
::sus::iter::IterRefCounter refs,
T* data,
sus::num::usize len) noexcept
static constexpr SliceMut<T>
from_raw_collection_mut(
::sus::marker::UnsafeFnMarker,
::sus::iter::IterRefCounter refs,
T* data,
sus::num::usize len) noexcept
Description
Constructs a slice from its raw parts with iterator invalidation tracking. Iterators produced from this slice will interact with the collection to allow it to know when they are being invalidated by the collection. For building a SliceMut from primitive pointer, use `from_raw_parts_mut()`. # Safety The following must be upheld or Undefined Behaviour may result: * The `refs` should be constructed from an `IterRefCounter` in the collection with `IterRefCounter::to_view_from_owner()`. * The `len` must be no more than the number of elements in the allocation at and after the position of `data`. * The pointer `data` must be a valid pointer to an allocation, not a dangling pointer, at any point during the SliceMut's lifetime. This must be true even if `len` is 0. In some other langages such as Rust, the slice may hold an invalid pointer when the length is zero. But `SliceMut` must not hold a dangling pointer. Otherwise addition on the dangling pointer may happen in SliceMut methods, which is Undefined Behaviour in C++. To support dangling pointers, those methods would need `length == 0` branches. Care must be applied when converting slices between languages as a result.
Declared at: sus/collections/slice.h:372
Parameters
¶static constexpr SliceMut<T> from_raw_parts_mut(
::sus::marker::UnsafeFnMarker,
T* data,
sus::num::usize len) noexcept
static constexpr SliceMut<T> from_raw_parts_mut(
::sus::marker::UnsafeFnMarker,
T* data,
sus::num::usize len) noexcept
Description
Constructs a slice from its raw parts. For building a SliceMut from a collection, use `from_raw_collection_mut()` in order to participate in iterator invalidation tracking. # Safety The following must be upheld or Undefined Behaviour may result: IterRefCounter and wants to be able to observe when it invalidates the `SliceMut` by tracking its lifetime. * The `len` must be no more than the number of elements in the allocation at and after the position of `data`. * The pointer `data` must be a valid pointer to an allocation, not a dangling pointer, at any point during the SliceMut's lifetime. This must be true even if `len` is 0. In some other langages such as Rust, the slice may hold an invalid pointer when the length is zero. But `SliceMut` must not hold a dangling pointer. Otherwise addition on the dangling pointer may happen in SliceMut methods, which is Undefined Behaviour in C++. To support dangling pointers, those methods would need `length == 0` branches. Care must be applied when converting slices between languages as a result.
Declared at: sus/collections/slice.h:342
Parameters
- ::sus::marker::UnsafeFnMarker
- T* data
- sus::num::usize len
¶constexpr Slice<T> operator Slice<
type - parameter - 0 - 0>() && noexcept
constexpr Slice<T> operator Slice<
type - parameter - 0 - 0>() && noexcept
Declared at: sus/collections/slice.h:451
¶constexpr Slice<T>& operator Slice<
type - parameter - 0 - 0>&() & noexcept
constexpr Slice<T>& operator Slice<
type - parameter - 0 - 0>&() & noexcept
Declared at: sus/collections/slice.h:450
¶constexpr const Slice<T>& operator const Slice<
type - parameter - 0 - 0>&() const& noexcept
constexpr const Slice<T>& operator const Slice<
type - parameter - 0 - 0>&() const& noexcept
Declared at: sus/collections/slice.h:447