Overloads of std.meta.staticIndexOf allow only to find an exact needle but in some case it more useful to get the index of something based on a predicate, for example to get the index of a compile time value that partially matches (e.g member value of a struct used as UDA). It even may be better to name them firstStaticIndexOf lastStaticIndexOf
This can be trivially done as a combination of existing templates: import std.meta; enum predStaticIndexOf(alias Fn, T...) = staticIndexOf!(true, staticMap!(Fn, T)); template MoreThan2(T...) { enum MoreThan2 = T[0] > 2; } unittest { static assert(predStaticIndexOf!(MoreThan2, 1,2,3) == 2); }
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9767 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB