View source code
Display the source code in std/variant.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Enum member std.variant.maxSize
Gives the sizeof
the largest type given.
enum maxSize(Ts...)
= Impl .sizeof;
See Also
https://forum.dlang.org/thread/wbpnncxepehgcswhuazl@forum.dlang.org?page=1
Example
struct Cat { int a, b, c; }
align(1) struct S
{
long l;
ubyte b;
}
align(1) struct T
{
ubyte b;
long l;
}
static assert(maxSize!(int, long) == 8);
static assert(maxSize!(bool, byte) == 1);
static assert(maxSize!(bool, Cat) == 12);
static assert(maxSize!(char) == 1);
static assert(maxSize!(char, short, ubyte) == 2);
static assert(maxSize!(char, long, ubyte) == 8);
import std .algorithm .comparison : max;
static assert(maxSize!(long, S) == max(long .sizeof, S .sizeof));
static assert(maxSize!(S, T) == max(S .sizeof, T .sizeof));
static assert(maxSize!(int, ubyte[7]) == 7);
static assert(maxSize!(int, ubyte[3]) == 4);
static assert(maxSize!(int, int, ubyte[3]) == 4);
static assert(maxSize!(void, int, ubyte[3]) == 4);
static assert(maxSize!(void) == 1);
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.