tail const
Simen kjaeraas
simen.kjaras at gmail.com
Thu Dec 2 16:54:51 PST 2010
Michel Fortin <michel.fortin at michelf.com> wrote:
> I'm not sure I get the problem. Can you show me in code?
const a = map!"a+a"( [1,2,3] );
foreach ( e; a ) {
}
The foreach fails because popFront is not const. What is needed is for
typeof(a) to be Map!("a+a", const(int)[]). IOW,
is( const(Map!("a+a", int[])) == Map!("a+a", const(int)[]) ).
One possible way to do this is for all types T to have defined types
immutable_t and const_t, which by default alias to immutable(T) and
const(T), but can be defined to alias to other types. The compiler
would then automagically convert cast(const)T to cast(T.const_t)T.
--
Simen
More information about the Digitalmars-d
mailing list