Advanced Meta Programming in Classic C++ | Davide Di Gennaro

Computer Programming and IT Books
Click Here To Download Book
Pages 589
Views 4113
Size 2.6 MB
Download 124
Table Of Contents

#include <pr er equisites>

Chapte r 1: T emplates

1.1. C++ T emplates

1.1.1. T ypename

1.1.2. Angl e Brackets

1.1.3. Uni versal Constructors

1.1.4. Functi on T ypes and Functi on Poi nters

1.1.5. Non-T empl ate Base Cl asses

1.1.6. T empl ate Posi ti on

1.2. Specializ ation and Argument Deduction

1.2.1. Deducti on

1.2.2. Speci al i z ati ons

1.2.3. Inner Cl ass T empl ates

1.3. Style Conventions


1.3.2. Macros

1.3.3. Symbol s

1.3.4. General i ty

1.3.5. T empl ate Parameters

1.3.6. Metafuncti ons

1.3.7. Namespaces and Usi ng Decl arati ons

1.4. Classic Patterns

1.4.1. si z e_t and ptrdi ff_t

1.4.2. voi d T : : swap(T&)

1.4.3. bool T : : empty() const; voi d T : : cl ear()

1.4.4. X T : : get() const; X T : : base() const

1.4.5. X T : : property() const; voi d T : : property(X)

1.4.6. Acti on(V al ue); Acti on(Range)

1.4.7. Mani pul ators

1.4.8. Posi ti on of Operators

1.4.9. Secret Inheri tance

1.4.10. Li teral Zero

1.4.1 1. Bool ean T ype

1.4.12. Defaul t and V al ue Ini ti al i z ati on

1.5. Code Safety

1.6. Compiler Assumptions

1.6.1. Inl i ne

1.6.2. Error Messages

1.6.3. Mi scel l aneous T i ps

1.7. Preprocessor

1.7.1. Incl ude Guards

1.7.2. Macro Expansi on Rul es

Chapte r 2: Smal l Obj e c t T ool ki t

2.1. H ollow T ypes

2.1.1. i nstance_of

2.1.2. Sel ector

2.1.3. Stati c V al ue

2.1.4. Si z e of Constrai nts

2.2. Static Assertions

2.2.1. Bool ean Asserti ons

2.2.2. Assert Legal

2.2.3. Asserti ons wi th Overl oaded Operators

2.2.4. Model i ng Concepts wi th Functi on Poi nters

2.2.5. Not Impl emented

2.3. T agging T echniques

2.3.1. T ype T ags

2.3.2. T aggi ng wi th Functi ons

2.3.3. T ag Iterati on

2.3.4. T ags and Inheri tance


Chapte r 3: Stati c P rogrammi ng

3.1. Static Programming with the Preprocessor

3.2. Compilation Complexity

3.3. Classic M etaprogramming Idioms

3.3.1. Stati c Short Ci rcui t

3.4. H idden T emplate Parameters

3.4.1. Stati c Recursi on on Hi dden Parameters

3.4.2. Accessi ng the Pri mary T empl ate

3.4.3. Di sambi guati on

3.5. T raits

3.5.1. T ype T rai ts

3.5.2. T ype Di smantl i ng

3.6. T ype Containers

3.6.1. typeat

3.6.2. Returni ng an Error

3.6.3. Depth

3.6.4. Front and Back

3.6.5. Fi nd

3.6.6. Push and Pop

3.6.7. More on T empl ate Rotati on

3.6.8. Aggl omerates

3.6.9. Conversi ons

3.6.10. Metafunctors

3.7. A Summary of Styles

Chapte r 4: Ove rl oad Re sol uti on

4.1. Groups

4.1.1. From Overl oad to Groups

4.1.2. Runti me Decay

4.2. M ore T raits

4.2.1. A Functi on Set for Stri ngs

4.2.2. Concept T rai ts

4.2.3. Pl atform-Speci fi c T rai ts

4.2.4. Mergi ng T rai ts


4.3.1. SFINAE Metafuncti ons

4.3.2. Mul ti pl e Deci si ons

4.3.3. Onl y_If

4.3.4. SFINAE and Returned Functors

4.3.5. SFINAE and Software Updates

4.3.6. Li mi tati ons and W orkarounds

4.3.7. SFINAE wi th Parti al Speci al i z ati ons

4.4. Other Classic M etafunctions with Siz eof

4.5. Overload on Function Pointers

4.5.1. Erase

4.5.2. Swap

4.5.2. Argument Domi nance

Chapte r 5: Inte rfac e s

5.1. W rapping References

5.2. Static Interfaces

5.2.1. Stati c Interfaces

5.2.2. Common Errors

5.2.3. A Stati c_Interface Impl ementati on

5.2.4. The Memberspace Probl em

5.2.5. Member Sel ecti on

5.3. T ype H iding

5.3.1. T rampol i nes

5.3.2. T ypei nfo W rapper

5.3.3. Opti on_Map

5.3.4. Opti on_Parser

5.3.5. Fi nal Addi ti ons

5.3.6. Boundary Crossi ng wi th T rampol i nes

5.4. V ariant

5.4.1. Parameter Del eti on wi th Vi rtual Cal l s

5.4.2. V ari ant wi th Vi si tors

5.5. W rapping Containers

Chapte r 6: Al gori thms

6.1. Algorithm I/O

6.1.1. Swap-Based or Copy-Based

6.1.2. Cl assi fi cati on of Al gori thms

6.1.3. Iterator Requi rements

6.1.4. An Exampl e: Set Parti ti oni ng

6.1.5. Identi fyi ng Iterators

6.1.6. Sel ecti on by Iterator V al ue T ype

6.2. Generaliz ations

6.2.1. Properti es and Accessors

6.2.2. Mi mesi s

6.2.3. End of Range

6.3. Iterator W rapping

6.3.1. Iterator Expander

6.3.2. Fake Pai rs

6.4. Receipts

6.5. Algebraic Requirements

6.5.1. Less and NaN

6.6. The B arton-Nackman T rick

Chapte r 7: Code Ge ne rators

7.1. Static Code Generators

7.2. Double checked Stop

7.3. Static and Dynamic H ashing

7.3.1. A Functi on Set for Characters

7.3.2. Changi ng Case

7.3.3. Mi mesi s T echni ques

7.3.4. Ambi guous Overl oads

7.3.5. Al gori thm I/O

7.3.6. Mi mesi s Interface

7.4. Nth M inimum

7.5. The T emplate Factory Pattern

7.6. Automatic E numeration of T ypes

7.7. If-L ess Code

7.7.1. Smart Constants

7.7.2. Converti ng Enum to Stri ng

7.7.3. Sel f-Modi fyi ng Functi on T abl es

Chapte r 8: F unc tors

8.1. Strong and W eak Functors

8.2. Functor Composition T ools

8.3. Inner T emplate Functors

8.3.1. Conversi on of Functi ons to Functors

8.3.2. Conversi on of Members to Functors

8.3.3. More on the Doubl e W rapper T echni que

8.4. Accumulation

8.4.1. A Step-by-Step Impl ementati on

8.5. Drivers

8.6. Algors

8.7. Forwarding and Reference W rappers

Chapte r 9: The Opaque T ype P ri nc i pl e

9.1. Polymorphic Results

9.2. Classic L ambda E xpressions

9.2.1. El ementary Lambda Obj ects

9.2.2. Lambda Functi ons and Operators

9.2.3. Refi nements

9.2.4. Argument and Resul t Deducti on

9.2.5. Deduci ng Argument T ype

9.2.6. Deduci ng Resul t T ype

9.2.7. Stati c Cast

9.2.8. Arrays

9.3. Creative Syntax

9.3.1. Argument Chai ns wi th ( ) and [ ]

9.4. The Growing Object Concept

9.4.1. Stri ng Concatenati on

9.4.2. Mutabl e Growi ng Obj ects

9.4.3. More Growi ng Obj ects

9.4.4. Chai n Destructi on

9.4.5. V ari ati ons of the Growi ng Obj ect

9.5. Streams

9.5.1. Custom Mani pul ators and Stream Inserti on

9.5.2. Range Inserti on wi th a Growi ng Obj ect

9.6. Comma Chains

9.7. Simulating an Infix


Chapte r 10: Re fac tori ng

10.1. B ackward Compatibility

10.2. Refactoring Strategies

10.2.1. Refactori ng wi th Interfaces

10.2.2. Refactori ng wi th T rampol i nes

10.2.3. Refactori ng wi th Accessors

10.3. Placeholders

10.3.1. Swi tch-Off

10.3.2. The Ghost

Chapte r 11: De buggi ng T empl ate s

1 1.1. Identify T ypes

1 1.1.1. T rappi ng T ypes

1 1.1.2. Incompl ete T ypes

1 1.1.3. T ag Gl obal V ari abl es

1 1.2. Integer Computing

1 1.2.1. Si gned and Unsi gned T ypes

1 1.2.2. References to Numeri c Constants

1 1.3. Common W orkarounds

1 1.3.1. Debuggi ng SFINAE

1 1.3.2. T rampol i nes

1 1.3.3. Compi l er Bugs

Chapte r 12: C++0x

12.1. T ype T raits

12.2. Decltype

12.3. Auto

12.4. L ambdas

12.5. Initializ ers

12.6. T emplate T ypedefs

12.7. E xtern T emplate

12.7.1. Li nki ng T empl ates

12.7.2. Extern T empl ate

12.9. V ariadic T emplates

Appe ndi x A: Exe rc i se s

A.1. E xercises

A.1.1. Extensi on

A.1.2. Integer

A.1.3. Date Format

A.1.4. Speci al i z ati on

A.1.5. Bi t Counti ng

A.1.6. Pri me Numbers

A.1.7. T ypei nfo wi thout R TTI

A.1.8. Hi nts and Parti al Sol uti ons