Today, I want to present the five winners for coupons for the book "Template Metaprogramming with C++" by Marius Bancila.
To get the book, you had to answer the following two questions by Marius Bancila:
- What do you find the most difficult about templates and why?
What would you like to learn more about templates?
I got about 15 answers. Here are the best five. I refer in the answers to the question 1 and 2 above.
- I think SFINAE is the hardest. The name is a self explanation why it is hard but let me expand it. The error messages are hard to read. SFINAE`s are hard to read. It takes some time to read and understand the code.
- I would like to learn more about constraints, concepts, requires expressions and fold expressions. I think these new features are very important. It can clear the most of the SFINAE code and increase readability and usability.
- Templates, similarly to library coding, are difficult as they have to be universal and most often independent in means they should not vary based on the parent's state. One may need to support as many types as possible, and once shuffling text-based, number-based with their variety of forms and separate error handling and validation these may become overburdened. This burden can be additionaly weighed down
Finally, programmers need to think about his program in high abstraction level, merged with language syntax and construction specifics. This brings a high complexity on reading, can form difficult DX (developer's experience) by introducing cognitive load.
- I am fresh in the world of Cpp, especially the modern one's so learning templates is a new road for me. They seem to be constructed similarly to C#'s generics, but I can see differences in their construction. What I think it is essential to learn from the very beginning for everyone are patterns and principles with strong introduction to abstract thinking, to develop lightweight yet functional templating abstractions, that may be universal across modern languages on the logical side.
- If I come across an unfamiliar template code usage for the first time, I need to do a bit of reverse engineering to understand the working of templates involved behind the usage. In other words, translating the metaprogramming to C++ code. This is done by the compiler itself but hidden from the developers.
- I aim to become a quality template meta programmer whc would use the appropriate template in appropriate situations. Sometimes, developers force their way to templates which makes code difficult to understand and maintain. Hence, I would start with using concepts for typename and also before unrestricted auto placeholder. Since this field is ever growing, I have to keep on my toes and learn about new features being introduced. Especially, how templates would help in making the code faster.
- Trivial and straightforward uses are clear to understand, even to someone unfamiliar to the language. However, conditionals, SFINAE, how to declare and use dependent types, alias template etc, are a language within C++ that not only takes time to learn and understand nuisances but something one must always keep practicing, otherwise, it is somewhat easy to forget the details.
- I would like to learn how to deliver the features while reducing dependencies on heavy template constructs. How to simplify template calls, specially when picking up legacy codebases for modernization. How to spread newer, and simpler best practices related with templates across lots of teams in big organizations - How to hide anything more "technically-deep" so programmers unfamiliar to complex template uses can still take advantage of them without feeling discouraged by C++.
- The most difficult thing for me is to figure out how to support different kinds of template parameters being passed to your functions: depending on cv qualifiers, pointers/refs, etc. Sometimes it's difficult to reason about and usually requires some Googling in order to properly decay them to their underlying types.
- Tbh, I would like to learn as much as possible as I never feel confident when I need to work with templates on my own.
Congratulations: Packt will contact you and send you the coupons.