Template function that accept strings and array of strings
badlink via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 16 12:24:05 PDT 2015
On Thursday, 16 July 2015 at 18:41:47 UTC, Gary Willoughby wrote:
> bool hasItemParent(A, B)(A itemId, B parentId)
> if (isSomeString!(A) && (isSomeString!(B) || isArray!(B) &&
> isSomeString!(ElementType!(B))))
Thank you ! I completely missed isSomeString.
I think the definition can be safely shortened to:
bool hasItemParent(T)(const(char)[] itemId, T parentId)
if (isSomeString!T || isSomeString!(ElementType!T))
Minor flaw, as it is the function also accepts wchar[] and
dchar[] that break the compilation because I do comparisons with
char[].
More information about the Digitalmars-d-learn
mailing list