Non-recursive maxSizeOf
Per Nordlöw
per.nordlow at gmail.com
Thu Aug 6 13:18:40 UTC 2020
On Thursday, 6 August 2020 at 13:07:14 UTC, Per Nordlöw wrote:
> Do you have any simple solution to this, H. S. Teoh?
I also tried
template maxSize(Ts...)
{
align(1) union Impl
{
// See_Also:
https://forum.dlang.org/thread/wbpnncxepehgcswhuazl@forum.dlang.org?page=1
static foreach (T; Ts)
{
static if (!is(T == void))
{
pragma(msg, T.stringof ~ " _store" ~ T.mangleof ~
";");
mixin(T.stringof ~ " _store" ~ T.mangleof ~ ";");
}
}
}
enum maxSize = Impl.sizeof;
}
but that fails because of types not being defined in scope such as
Cat _storeS3std7variant17__unittest_L96_C7FNfZ3Cat;
/home/per/Work/phobos/std/variant.d-mixin-88(88,5): Error:
undefined identifier `Cat`
Can somebody find a better alternative?
More information about the Digitalmars-d-learn
mailing list