TData

A reference to a reference-counted block of memory. Represents a slice of data, which may be backed by managed memory, unmanaged memory, memory-mapped files, etc.

struct TData (
T
) if (
!hasIndirections!T
) {}

Constructors

this
this(U[] data)

DWIM constructor for creating a new instance wrapping the given data.

this
this(typeof(null) n)

Create a new null-like instance.

this
deprecated this(U[] data)
Undocumented in source.
this
this(size_t size, size_t capacity)

Create a new instance with given size/capacity. Capacity defaults to size.

this
this(Memory memory)

Create a new instance slicing all of the given memory's contents.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

opDollar
alias opDollar = length
Undocumented in source.

Functions

asDataOf
auto asDataOf()

Soft (memory-safe) cast: Cast contents to another type, and returns an instance with that contents. Constness is preserved. No copying is done.

castTo
TData!U castTo()

Hard (normally memory-unsafe) cast: Cast contents to another type, and returns an instance with that contents. The current instance is cleared. U may have an incompatible constness. To enforce memory safety, the current instance must be the only one holding a reference to the data (call ensureUnique first). No copying is done.

clear
void clear()

Unreference contents, freeing it if this was the last reference.

deleteContents
deprecated void deleteContents()
Undocumented in source.
ensureUnique
TData ensureUnique()

Returns an instance with the same data as the current instance, and a reference count of 1. The current instance is cleared. If the current instance already has a reference count of 1, no copying is done.

enter
void enter(void delegate(scope T[]) fn)

Get temporary access to the data referenced by this Data instance.

enter
void enter(void delegate(scope T[]) @(safe) fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) nothrow fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) @(safe) nothrow fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) @(nogc) fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) @(safe) @(nogc) fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) nothrow @(nogc) fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
void enter(void delegate(scope T[]) @(safe) nothrow @(nogc) fn)
Undocumented in source. Be warned that the author may not have intended to support it.
enter
auto enter(Dg fn)
Undocumented in source. Be warned that the author may not have intended to support it.
front
T front()
Undocumented in source. Be warned that the author may not have intended to support it.
indexOf
sizediff_t indexOf(const(T)[] needle)
Undocumented in source. Be warned that the author may not have intended to support it.
indexOf
deprecated sizediff_t indexOf(const(void)[] needle)
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
void opAssign(typeof(null) )

Allow assigning null to clear.

opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
T opIndex(size_t index)

Access an individual item.

opIndexAssign
T opIndexAssign(T value, size_t index)

Write an individual item.

opSlice
TData opSlice()
TData opSlice(size_t x, size_t y)

Returns a Data pointing at a slice of this Data's contents.

popFront
void popFront()
Undocumented in source. Be warned that the author may not have intended to support it.
toGC
T[] toGC()

Put a copy of the data on D's managed heap, and return it.

toHeap
deprecated T[] toHeap()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

capacity
size_t capacity [@property getter]

Return the maximum value that can be set to length without causing a reallocation

contents
deprecated inout(T)[] contents [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
dup
This dup [@property getter]

Create a copy of the data

empty
bool empty [@property getter]

Range primitive.

length
size_t length [@property getter]
length
size_t length [@property setter]

Resize contents

mcontents
deprecated Unqual!T[] mcontents [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
mptr
deprecated Unqual!T* mptr [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
ptr
deprecated inout(T)* ptr [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
unsafeContents
inout(T)[] unsafeContents [@property getter]

Get the referenced data. Unsafe!

Static functions

wrapGC
TData wrapGC(T[] data)

Create a new instance which slices some range of managed (GC-owned) memory. Does not copy the data.

Templates

opBinary
template opBinary(string op)

Create a new Data containing the concatenation of this and data. Does not preallocate for successive appends.

opBinaryRight
template opBinaryRight(string op)

Create a new Data containing the concatenation of data and this. Does not preallocate for successive appends.

opOpAssign
template opOpAssign(string op)

Append data to this Data. Unlike concatenation (a ~ b), appending (a ~= b) will preallocate.

Parameters

T

the element type. "void" has a special meaning in that memory will not be default-initialized.

Meta