Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Is uint as index correct?

Moderators: kris

Posted: 02/28/09 12:11:06

The various functions that takes and/or returns an index in an array for example in tango.text.Util look like this:

uint locate(T, U=uint) (T[] source, T match, U start=0)

T as the type of the array and U as the type of the index, defaults to uint.

1. Shouldn't that return U?
2. Shouldn't U be size_t as default?

The above function calls a function that looks likes this:

uint locate(T) (T[] source, T match, uint start=0)

3. There is no U here, only uint. What's the point with U in the first function if this is uint?

Author Message

Posted: 02/28/09 19:28:46

those templates act as wrappers only: they avoid an explosion of redundant template-instantiations

Posted: 02/28/09 20:31:22

But shouldn't uint be size_t?

Posted: 02/28/09 22:13:19

Perhaps, yes. There's been some recent changes to use size_t in other places within Tango, so it will likely happen there also