Page 1. Template Metaprogramming in C++. CS242, Fall 2009. Keith Schwarz.
Page 2. Preliminaries. Page 3. A C++ template is a type or function.
This paper describes the Boost C++ template metaprogramming library (MPL), an
extensible ..... Here we have introduced the notion of a type computation.
... Concepts, Tools, and Techniques from Boost and Beyond Book, Online Download C++ Template ... from Boost and Beyond,
1. Document # N1471/03-0054. April 18, 2003. Reflective Metaprogramming in
C++. Daveed Vandevoorde. Edison Design Group. Topics/Overview.
The great achievement of the game theory arises form the wide variety of fields in which it has ... caly determine the payoff space for normal-form C1 parametric games in two ..... solutions as new policy tools, TPREF-Theoretical and Practical Re- ..
features of the command language used to configure Cisco routers. ... These are
the traceroute command, which displays the route between two hosts on the ...
Page 1. Chapter 8. The Dynamic Planet. Elemental Geosystems 5e. Robert W.
Christopherson. Charles E. Thomsen. Page 2. Page 3. Page 4. The Dynamic ...
Learning Objective To recall and review the knowledge of various types of quadn'
laterals. ... Execution of task Cut-outs of various type of quadrilaterals can be.
24 traces. 5. Amberjet 1200 H. 24. NR. 6. Amberlite IR 120. 24. NR. 7. H2SO4. 2.
90. 8 p-TsOH. 6. 80. 9. Sulfamic acid. 12. 78 a. 100 mg of the catalyst was used.
41. CHAPTER EIGHT. LOAN CONSOLIDATION. To apply for a Direct Loan
Consolidation, the borrower must contact the Direct Loan Origination. Center's ...
distinguish between linear momentum and angular momentum. State and apply
the law of conservation of angular momentum to solve word problems. calculate ...
To provide to instructors an overview of Chapter 8: ITE PC v4.0 ... Chapter 8
Worksheets, Activities, and Labs ... 8.10.3 Worksheet: Answer Broadband
Questions. ▫ 8.12.2 ..... Thicknet or 10Base5 - Coax cable that was used in
networks.
and averaging looks just like an EEG signal, so many saw MEG as an expensive EEG ...... Ioannides, A.A., and Taylor, J.G. (1999) Min- imum norm, Magnetic ...
homolog IMB-4/CRM-1 (31, 32). Furthermore, LIT-1 modi- fication of POP-1 was shown to be required for its asymmet- ric nuclear distribution in a process that ...
(1) Accounts Officer – means the Head of an office of Accounts or the Head of a ...
(2) Administrative Approval – This terms denotes the formal acceptance, by the ...
Examples: Recoveries of advances or recoverable payment, and sale .....
expendit
Campbell Biology: Concepts & Connections, Seventh Edition. Reece, Taylor,
Simon, and Dickey. Chapter 8 The Cellular Basis of Reproduction and
Inheritance.
Quantum. Physics of atoms, molecules,Solids,nuclei and Particles. Eisberg &
Resnick. ○ What holds atom together? Electric forced hold atoms together to
form ...
... sum of the variances: 2. 2. ,. ,. Var(. ) Var( ) Var( ) i ie i ie f v. f v f v σ σ. +. = +. = +
. (ii) We compute the covariance between any two of the composite errors as.
equity investments under the cost method, the mark-to-market method, the equity
method, ... method, the cost method, and the equity method of accounting for.
2004), and the 2006 global laptop battery recall by several major laptop ... fetch an even higher price tag than the new game (without the mini-game). Some ...... ample, in Star Wars Galaxy, players may choose at the onset to sign up as a mem-.
4 Ibid., p. 138. 5 The Suez Canal had been governed under the provisions of ..... delegation in Bandung, Turkish Foreign Minister Fatin Rustii Zorlu, tried to prove.
Review In Lactam Compounds ((Methods of Preparation,. Reactions .... Vogels Text Book of "Practical Organic Chemistry" ;3rd London Inc ; New. York, 1974. ... Ralph L,Shriner and Reynold C . Fuson ,"The systematic identification of organic ...
AP Chemistry. A. Allan. Chapter 8 Notes - Bonding: General Concepts. 8.1 Types
of Chemical Bonds. A. Ionic Bonding. 1. Electrons are transferred. 2. Metals ...
Chapter 8. Initial Value problems in multiple dimensions. Selected Reading.
Numerical Recipes, 2nd edition: Chapter 19. 8.1 Introduction. Nearly all of the ...
This definition characterizes the main idea of metaprogramming, which involves
... manipulates another program is clearly an instance of metaprogramming.
251
Chapter 8
Static Metaprogramming in C++142
252
8.1
Generative Programming, K. Czarnecki
What Is Static Metaprogramming?
In linguistics, a metalanguage is defined as follows [Dict]:
Metalanguage
“any language or symbolic system used to discuss, describe, or analyze another language or symbolic system”
This definition characterizes the main idea of metaprogramming, which involves writing programs related by the meta-relationship, i.e. the relationship of “being about”. A program that manipulates another program is clearly an instance of metaprogramming. In Section 7.4.7, we saw other instances of metaprogramming which do not necessarily involve program manipulation (e.g. before and after methods143); however, in this chapter we focus on generative metaprograms, i.e. programs manipulating and generating other programs.
Metaprogramming
Generative metaprograms
generative metaprogram = algorithm + program representation Metaprograms can run in different contexts and at different times. In this chapter, however, we only focus on static metaprograms. These metaprograms run before the load time of the code they manipulate.144
Static metaprograms
The most common examples of systems involving metaprogramming are compilers and preprocessors. These systems manipulate representations of input programs (e.g. abstract syntax trees) in order to transform them into other languages (or the same language as the input language but with a modified program structure). In the usual case, the only people writing metaprograms for these systems are compiler developers who have the full access to their sources. The idea of an open compiler is to make metaprogramming more accessible to a broader audience by providing well-defined, high-level interfaces for manipulating various internal program representations (see e.g. [LKRR92]). A transformation system is an example of an open compiler which provides an interface for writing transformations on abstract syntax trees (ASTs). We discussed them in Section 6.3. An open compiler may also provide access to the parser, runtime libraries, or any other of its parts. The Intentional Programming System is a good example of a widely-open programming environment. Unfortunately, currently no industrial-strength open compilers are commercially available (at least not for the main-stream object-oriented languages).145
8.2
Template Metaprogramming
A practicable approach to metaprogramming in C++ is template metaprogramming. Template metaprograms consist of class templates operating on numbers and/or types as data. Algorithms are expressed using template recursion as a looping construct and class template specialization as a conditional construct. Template recursion involves the direct or indirect use of a class template in the construction of its own member type or member constant. Here is an example of a class template146 which computes the factorial of a natural number: template struct Factorial { enum { RET = Factorial::RET * n }; }; //the following template specialization terminates the recursion template struct Factorial { enum { RET = 1 };
Open compilers
Static Metaprogramming in C++
253
};
We can use this class template as follows: void main() { cout