Overloaded opApply for named template mixin
    Simen Kjaeraas 
    simen.kjaras at gmail.com
       
    Wed Nov 12 05:33:52 PST 2008
    
    
  
On Wed, 12 Nov 2008 11:37:33 +0100, Christian Hartung  
<christian.s77 at gmail.com> wrote:
> 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)
>      {
>      }
> }
>
Ah, but that does not give me the named mixin.
Consider
class Tree(T)
{
	mixin Traverse!(Stack) depthfirst;
	mixin Traverse!(Queue) breadthfirst;
}
-- 
Simen
    
    
More information about the Digitalmars-d-learn
mailing list