On 04/24/2012 07:37 PM, H. S. Teoh wrote:
I'm trying to write a template function for doing member-wise
comparisons between two objects, with an optional list of members to
ignore. But I can't seem to figure out the syntax for passing a list of
strings (or an AA of strings) to the function?
I tried this:
bool compareByMemb(string[] ignores, T)(T obj1, T obj2) {
foreach (name; __traits(getAllMembers, T)) {
...
}
}
but the compiler complains:
Error: arithmetic/string type expected for value-parameter, not string[]
What gives?
T
Try using an alias parameter (with an optional type constraint). imo the
template instantiation semantics needs a clean-up.