Widths

Calculates the minimum padding needed to accommodate the strings of all the types and names of the members of the passed struct and/or classes, for formatting into neat columns.

private
template Widths (
Flag!"all" all
Things...
) {
static if(all)
enum type;
private
static if(all)
enum initialWidth;
static if(!(all))
enum type;
private
static if(!(all))
enum initialWidth;
private
enum ptrdiff_t compensatedWidth;
enum ptrdiff_t name;
}

Parameters

all

Whether or not to also include Unserialisable members.

Things

Variadic list of aggregates to introspect.

Examples

import std.algorithm.comparison : max;

struct S1
{
    string someString;
    int someInt;
    string[] aaa;
}

struct S2
{
    string longerString;
    int i;
}

alias widths = Widths!(No.all, S1, S2);

static assert(widths.type == max(minimumTypeWidth, "string[]".length));
static assert(widths.name == max(minimumNameWidth, "longerString".length));