Template reference parameter

rumbu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 23 15:01:03 PDT 2015


I'm trying to construct a struct template where one of the 
template parameters is passed by reference (as option)

struct S(T, U)
{
    void opCall(T t, U u) { }
}

alias X = S!(T, U);
alias RX = S!(T, ref U); //not working

The objective is  to call X(t, u) or RX(t, u), but in second case 
I want "u" to be passed by reference.

The only solution I found is to pass U as a pointer or as a class.


More information about the Digitalmars-d-learn mailing list