C++ or D?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Dec 30 21:12:43 UTC 2020


On Wednesday, 30 December 2020 at 20:42:49 UTC, jmh530 wrote:
> You mean like this
>
> struct Foo(T)
> {
>     T x;
> }
>
> void foo(T : Foo!V, V)(T x) {


Not quite, "Foo" would be a template parameter, so something like 
this (which does not work, but maybe there is some other way to 
express it?):


struct Foo(T)
{
     T x;
}


void foo(T)(T!int x) {
     import std.stdio: writeln;
     writeln("here");
}

void main() {
     Foo!int x;
     foo(x);
}






More information about the Digitalmars-d-learn mailing list