const debacle

Janice Caron caron800 at googlemail.com
Fri Mar 21 11:31:26 PDT 2008


On 21/03/2008, Sean Kelly <sean at invisibleduck.org> wrote:
> Use overloaded functions.  In theory, I think this should work:
>
>  T[] func(T)( T[] buf ) { ... }
>  const T[] func(T)( const T[] buf ) { ... }
>  invariant T[] func(T)( invariant T[] buf ) { ... }

I really wish there was a better way of doing it though. Essentially,
we want a way to auto-generate all three versions of

    K(T)[] func(T)(K(T)[] buf ) { ... }

where K() can be used anywhere within scope, and where K(U) expands to
each of U, const(U) and invariant(U) in succession. That would be /so/
much nicer than all that messing about with TransferConst!

Obviously, K is not the best choice of keyword! :-)



More information about the Digitalmars-d mailing list