Skip to content

Template specialisation syntax #1284

Answered by MaxSagebaum
tcbrindle asked this question in Q&A
Discussion options

You must be logged in to vote

It is currently not possible. There is merge request which addresses this #598.

If this is merged the syntax would look like: https://cpp2.godbolt.org/z/KP4cGjscK

A: <E,C> type = {
    print: (this) = {
        std::cout << "A normal" << std::endl;
    } 
}

A: <C> specialize<C,C> type = {
    print: (this) = {
        std::cout << "A specialized" << std::endl;
    }
}

main: () = {
    a1: A<double, int> = ();
    a2: A<double, double> = ();

    a1.print();
    a2.print();
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tcbrindle
Comment options

Answer selected by tcbrindle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants