by jcelerier · 5y ago · 0 comments
I mean, seriously,
func F[T any](p T) { ... } template<typename T>
void F(T p) { ... }Generics in Go are vastly different than templates in C++. They might be used for similar things, but whereas Go's generics actually build up on Go's structural typing, templates are ... something completely different again.
I mean; C++ templates are Turing complete. They are in the same ballpark as Scala's type machinery. And I say that with adoration.
that's not a very high milestone to achieve. Even java generics are turing complete (https://arxiv.org/abs/1605.05274)
template<SomeConstraint T>
void F(T p) { ... }
or just void F(SomeConstraint auto p) { ... }
like this for instance: https://gcc.godbolt.org/z/hPM38T