Comment

Comment by chadzawistowski

I think of templates as an automated copy+paste mechanism. C++ templates can bloat the compiled executable pretty significantly... If you define a generic Foo<String> and Foo<Widget>, C++ templates will generate two separate binary implementations. C# will use the same implementation, and perform type checks using reflection at runtime.

Further support for the idea that C++ templates are an automated copy+paste mechanism is that you're allowed to give templates arguments that are not types.

Further reading: https://msdn.microsoft.com/en-us/library/c6cyy67b.aspx

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton