Type-qualified functions?

Christopher Nicholson-Sauls ibisbasenji at gmail.com
Sat Jan 22 05:22:52 PST 2011

On 01/21/11 14:43, Sean Eskapp wrote:
>> templates:
>> void foo(T)(T, void delegate(T) fn)
>> {
>> }
>> This parameterizes foo based on T, which could be A, const A, or int, or
>> whatever works to compile the function.
> What if the parameters are more general, for instance the first parameter is
> always a Foo, the second is a delegate which takes a Foo.Bar, but they're always
> qualified the same way?

I believe this is the sort of thing the 'inout' qualifier was meant for,
except I don't know if it works with a void return type.  It's also
worth noting that mutable and immutable are both castable to const, so
if there is literally no difference between the two functions, see if
you can get away with just the one using const.

-- Chris N-S

More information about the Digitalmars-d-learn mailing list