I do most of my work in C# now, and templates are what I miss most from C++. The syntax is, well, horrible, but the things you can do really help eliminate what would otherwise be redundant code. Just make sure you comment the hell out of things like this or the people that have to read and maintain your code later will hate you.
An introduction to C++'s variadic templates: a thread-safe multi-type map
11–19 of 19 posts
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#12I do most of my work in C# now, and templates are what I miss most from C++. The syntax is, well, horrible, but the things you can do really help eliminate what would otherwise be redundant code. Just make sure you comment the hell out of things like this or the people that have to read and maintain your code later will hate you.
Variadic templates add new syntax but they make some previously very tedious things relatively trivial once you understand the syntax.
C++17 will bring some further improvements when writing templates. Concepts lite will be a huge deal but there are a number of other niceties too, some already available in clang.
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#13I do most of my work in C# now, and templates are what I miss most from C++. The syntax is, well, horrible, but the things you can do really help eliminate what would otherwise be redundant code. Just make sure you comment the hell out of things like this or the people that have to read and maintain your code later will hate you.
I see it as a language in itself. Once done with the steep learning curve you start to observe repeated patterns and get it more easily. I do agree that the syntax is a huge drawback from now.
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#14I do most of my work in C# now, and templates are what I miss most from C++. The syntax is, well, horrible, but the things you can do really help eliminate what would otherwise be redundant code. Just make sure you comment the hell out of things like this or the people that have to read and maintain your code later will hate you.
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#15Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#16Earlier quoted context omitted.
I see it as a language in itself. Once done with the steep learning curve you start to observe repeated patterns and get it more easily. I do agree that the syntax is a huge drawback from now.
Yup, it's definitely its own language! It made me so happy when I saw a Haskell-to-C++-template compiler [1] because of all the similarities in pure-FP style (pattern matching, iteration via recursion, etc). [1] https://gergo.erdi.hu/projects/metafun/
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#17This is an excellent write-up on some really great additions to the C++ language that make type-safe programming more flexible.
Thank your Sir! Sadly C++ drags a bad reputation from its earlier years. I wish my posts make C++ reachable and enjoyable for common guys like me.
I suppose it doesn't matter since the concepts proposal was torpedoed. (But that's another story.)
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#18Earlier quoted context omitted.
Thank your Sir! Sadly C++ drags a bad reputation from its earlier years. I wish my posts make C++ reachable and enjoyable for common guys like me.
In a somewhat misspent youth, I was a grad student of Jaakko Järvi when he and the rest of the Indiana folk were pitching variadic templates and concepts. I was browbeat into attempting to add concept constrained variadic templates to GCC. So... it turns out, for this problem, for precise constraints, the number of constraints is strongly exponential (factorial of factorials). I think we ended up going with the inter…
Re: An introduction to C++'s variadic templates: a thread-safe multi-type map
#19Earlier quoted context omitted.
In a somewhat misspent youth, I was a grad student of Jaakko Järvi when he and the rest of the Indiana folk were pitching variadic templates and concepts. I was browbeat into attempting to add concept constrained variadic templates to GCC. So... it turns out, for this problem, for precise constraints, the number of constraints is strongly exponential (factorial of factorials). I think we ended up going with the inter…
I yet didn't check the proposal for C++17 concepts, it seems to constantly change since C++11. Does it includes anything related to variadic templates? Anyway, you must have had a lot of fun with Jaakko Järvi as a teacher!