Choosing between enum arrays or AliasSeqs
Nordlöw via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 24 23:12:42 PDT 2017
On Thursday, 24 August 2017 at 22:38:29 UTC, Meta wrote:
> https://dlang.org/phobos/std_meta.html#aliasSeqOf
Thanks!
Your advice led to the following sample solution
import std.meta : aliasSeqOf;
immutable englishIndefiniteArticles = [`a`, `an`];
bool isEnglishIndefiniteArticle(S)(S s)
{
return
cast(bool)s.among!(aliasSeqOf!englishIndefiniteArticles);
}
Is this the preferred way?
Could a template-parameter overload to `among` (perhaps calling
it something slighty different) be defined that takes an
immutable array as argument to prevent the conversion to the
`AliasSeq` prior to the call?
More here:
https://github.com/nordlow/phobos-next/blob/c7d9a0f9c3280fc7852584ee2be387646a5f7857/src/grammar.d#L49
More information about the Digitalmars-d-learn
mailing list