Combining template parameters deduction with default template parameters

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Mar 23 04:14:55 PDT 2014


On 3/23/14, Uranuz <neuranuz at gmail.com> wrote:
> I have a question how I could combine template parameters
> deduction with setting default values for template parameters. I
> will start directly from a piece of code.

You can use eponymous templates for this. E.g.:

-----
template decodeURICustom(string allowedSpecChars = null, bool
formEncoding = false)
{
    string decodeURICustom(T)(T source) pure
    {
        return "";
    }
}

alias decodeURICustom!("!$&'()*+,;=") decodeURIHost;

void main()
{
    string str    = "http://www.dlang.org";
    string result = decodeURICustom(str);
}
-----


More information about the Digitalmars-d-learn mailing list