The OpenD Programming Language

member

Field (element's member) projection.

  1. Slice!(MemberIterator!(Iterator, name), N, kind) member(Slice!(Iterator, N, kind) slice)
    template member(string name)
    Slice!(MemberIterator!(Iterator, name), N, kind)
    member
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    )
    if (
    name.length
    )
  2. Slice!(MemberIterator!(T*, name)) member(T[] array)
  3. auto member(T withAsSlice)

Members

Functions

member
Slice!(MemberIterator!(Iterator, name), N, kind) member(Slice!(Iterator, N, kind) slice)
Slice!(MemberIterator!(T*, name)) member(T[] array)
auto member(T withAsSlice)

Parameters

name

element's member name

Return Value

lazy n-dimensional slice of the same shape

Examples

// struct, union or class
struct S
{
    // Property support
    // Getter always must be defined.
    double _x;
    double x() @property
    {
        return x;
    }
    void x(double x) @property
    {
        _x = x;
    }

    /// Field support
    double y;

    /// Zero argument function support
    double f()
    {
        return _x * 2;
    }
}

import mir.ndslice.allocation: slice;
import mir.ndslice.topology: iota;

auto matrix = slice!S(2, 3);
matrix.member!"x"[] = [2, 3].iota;
matrix.member!"y"[] = matrix.member!"f";
assert(matrix.member!"y" == [2, 3].iota * 2);

See Also

Meta