Overloaded opApply for named template mixin
Christian Hartung
christian.s77 at gmail.com
Wed Nov 12 02:37:33 PST 2008
Em Wed, 12 Nov 2008 01:57:41 -0200, Simen Kjaeraas
<simen.kjaras at gmail.com> escreveu:
> Right, I have this:
>
> template foo(T)
> {
> int opApply(int delegate(ref T) dg)
> {
> // code here
> }
> }
>
> class bar(T)
> {
> mixin foo!(T) baz;
> }
>
> void main()
> {
> bar b = new bar();
> foreach(qux; bar.baz)
> {
> }
> }
>
> And it does not compile. The error I get is "expression has no value",
> on the line with the foreach. Do I need to do this in a different way,
> or is it simply not possible (at the moment)?
>
Currently the right way to do this is:
template foo(T)
{
int opApply(int delegate(ref T) dg)
{
// code
}
}
class bar(T)
{
mixin foo!(T);
}
void main()
{
auto b = new bar!(int);
foreach(qux; b)
{
}
}
--
Usando o revolucionário cliente de e-mail do Opera:
http://www.opera.com/mail/
More information about the Digitalmars-d-learn
mailing list