Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
On Friday, 25 August 2017 at 08:27:41 UTC, Jacob Carlborg wrote: Since you're converting the returned index to a bool, can't you use "canFind" instead? immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) { return englishIndefiniteArticles.canFind(s);

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 08:12, Nordlöw wrote: 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

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
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) {

Re: Choosing between enum arrays or AliasSeqs

2017-08-24 Thread Meta via Digitalmars-d-learn
On Thursday, 24 August 2017 at 19:41:46 UTC, Nordlöw wrote: Given enum e = ['a', 'b', 'c']; import std.meta : AliasSeq; enum a = AliasSeq!['a', 'b', 'c']; is it somehow possible to convert (at compile-time) `e` to `a`? Is it cheaper CT-performance wise to use AliasSeq instead of

Choosing between enum arrays or AliasSeqs

2017-08-24 Thread Nordlöw via Digitalmars-d-learn
Given enum e = ['a', 'b', 'c']; import std.meta : AliasSeq; enum a = AliasSeq!['a', 'b', 'c']; is it somehow possible to convert (at compile-time) `e` to `a`? Is it cheaper CT-performance wise to use AliasSeq instead of enum static arrays? My use case is expressed by the TODOs in