Can you do 'MyType<n> foo(int n) {...}' ?
I don't know enough about C++ templates here, but you cannot in Rust.
> How is that done in languages that do support this?
I don't know enough about the implementations to actually say, to be honest. Most of them aren't systems languages, and so have significantly less constraints on implementations, and less monomorphization. I imagine that helps.
Like, if I can have a type Array<Type,Length> and have a function f which has as its input type Int, with the name of the input variable being n, and as its return type Array<Bool,n> and when you give the return value to something else, it checks (at compile time) that the length of the array (i.e. , n ) matches what the other thing is expecting,
that would be using dependent types.