Mercurial > projects > orange
changeset 7:32152d5fad4b
nameOfFieldAt fails poorly if position >= tuple.length
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 25 Jun 2010 23:07:49 +0200 |
parents | ae24aae69a3b |
children | 613a0bb20207 |
files | orange/util/Reflection.d |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/orange/util/Reflection.d Fri Jun 25 20:27:27 2010 +0200 +++ b/orange/util/Reflection.d Fri Jun 25 23:07:49 2010 +0200 @@ -258,7 +258,7 @@ } /** - * Evaluates to a string containing the name of the field at given position in the type given type. + * Evaluates to a string containing the name of the field at given position in the given type. * * Params: * T = the type of the class/struct @@ -266,6 +266,8 @@ */ template nameOfFieldAt (T, size_t position) { + static assert (position < T.tupleof.length, format!(`The given position "`, position, `" is greater than the number of fields (`, T.tupleof.length, `) in the type "`, T, `"`)); + static if (T.tupleof[position].stringof.length > T.stringof.length + 3) const nameOfFieldAt = T.tupleof[position].stringof[1 + T.stringof.length + 2 .. $];