Download Advanced Metaprogramming in Classic C++ (3rd Edition) by Davide Di Gennaro PDF

By Davide Di Gennaro

Complex Metaprogramming in vintage C++ bargains a close investigate C++ template metaprogramming (TMP); TMP is gifted within the e-book as a suite of thoughts that might carry a brand new sort in C++ and making it exceedingly transparent and effective. The e-book offers with language facets, layout styles, examples and functions (seen as case studies). specific emphasis is wear small reusable thoughts that might increase the standard of day-by-day work.

The e-book teaches metaprogramming utilizing vintage C++, that's, now not utilizing the 2 more moderen criteria. this can be performed to maximise compatibility and obviously illustrate the approach, permitting the reader to realize tricky fabric with out the burdens of compiler error, and different pointless complexities and allowing a way more excessive therapy of the topic. In so doing, all next additions to the C++ language are totally appropriate with the code during this e-book and clients acquainted with them can leverage the techniiques brought in C++ XX to make the styles during this booklet much more robust. there's a bankruptcy even though that discusses matters concerning the more moderen standards.

What makes the e-book extraordinary is the extent of realizing of the suggestions concerned imparted via the writer. this isn't only a rote evaluation of metaprogramming. you are going to actually comprehend tricky subject matters like static assertions, easy methods to write metafunctions, overload answer, lambda expressions, and so forth. greater than that, you'll paintings via them with functional examples guided through the author's frank causes. This publication calls for you to imagine and to benefit and to appreciate the language that you can software at the next level.

What you’ll learn

What templates and the small item toolkit are, and the way to exploit them
the way to do overload resolution
how one can do metaprogramming with interfaces, algorithms, functors and refactoring
the right way to paintings with code generators
what's opaque sort precept and the way to exploit it
the right way to paintings with debugging templates and more
A bankruptcy dedicated to concerns surrounding C++0x and C++14

Who this booklet is for

This publication is for skilled C++ programmers who are looking to study more.
Table of Contents

Part I

1. Templates

2. Small item Toolkit

Part II

3. Static Programming

4. Overload Resolution

5. Interfaces

6. Algorithms

7. Code Generators

8. Functors

9. Opaque style Principle

Part III

10. Refactoring

11. Debugging Templates

12. C++0X

13. Appendix A: Exercises

14. Appendix B: Bibliography

Show description

Read or Download Advanced Metaprogramming in Classic C++ (3rd Edition) PDF

Best programming books

Beginning Perl (3rd Edition)

It is a publication for these people who believed that we didn’t have to study Perl, and now we all know it truly is extra ubiquitous than ever. Perl is very versatile and strong, and it isn’t scared of internet 2. zero or the cloud. initially touted because the duct tape of the web, Perl has in view that advanced right into a multipurpose, multiplatform language current completely all over the place: heavy-duty internet functions, the cloud, platforms management, common language processing, and monetary engineering.

Extra info for Advanced Metaprogramming in Classic C++ (3rd Edition)

Sample text

The suffix _t, which in C originally means typedef, is also widely used for (private) typedefs standing for template instances: template class SomeContainer { // informally means: // within this class, a pair always denotes a pair of scalars private: typedef std::pair pair_t; }; On the other hand, a public typedef name usually is composed of lowercase regular English words (such as iterator_category). 6. Metafunctions We often meet stateless class templates whose members are only enumerations (as a rule, anonymous), static constants, types (typedefs or nested classes), and static member functions.

B : a; } template struct SomeClass { static const int value = sq(N)/max(N, 1); Finally, consider a special class of macros. A macro directive is a macro whose usage logically takes an entire line of code. 1415926535897932384626433832795029 // the use of MXT_PI does not take the whole line // so it is not a directive. const double x = std::cos(MXT_PI); // directive MXT_NULL_NAMESPACE_END() The definition of a macro directive, in general, should not end with a semicolon, so the user is forced to close the line manually (when appropriate), as if it were a standard function call.

Macros Macros play a special role in TMP. Some programmers consider them a necessary evil and indeed they are necessary, but it’s not obvious they are also evil. Macros must: • Allow the reader to recognize them • Prevent name collisions As discussed in [5], usually member function names should be actions. Thus empty should be a synonym for make_empty and not for is_empty. However, STL convention is established and universally understood. When in doubt, do as std::vector does. 27 41 Chapter 1 ■ Templates The easiest way to satisfy both requirements is to choose a unique and sufficiently ugly common prefix for all macros and play with lower/uppercase to give extra meaning to the name.

Download PDF sample

Rated 4.13 of 5 – based on 22 votes