Starting to use the new templates

[SVN r12718]
This commit is contained in:
Vesa Karvonen
2002-02-05 08:27:20 +00:00
parent 6248559797
commit 41d99b49e4
8 changed files with 239 additions and 172 deletions

40
doc/acknowledgements.htm Normal file
View File

@ -0,0 +1,40 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Acknowledgements</title>
</head>
<body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Acknowledgements</h2>
</td>
</tr>
</table>
<hr>
<p>The original idea of passing two extra parameters to REPEAT, which makes it
possible to create preprocessor code on top of it, was due to Aleksey Gurtovoy.
The invokeable IDENTITY macro was also invented by him. He also suggested the
name for the library. Many thanks to Aleksey for his insights!</p>
<p>Thanks to everyone who participated in the review: David Abrahams, Beman Dawes,
Ronald Garcia, Douglas Gregor, Aleksey Gurtovoy, Jeremy Siek, and Daryle Walker.</p>
<p>Thanks to Chris Little and Mat Marcus for providing help with MWCW.</p>
<p>The PREPROCESSOR library has been developed by Vesa Karvonen. </p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
"as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body>
</html>

View File

@ -1,16 +1,22 @@
<html> <html>
<head> <head>
<title>Boost PREPROCESSOR library</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Tutorial examples preprocessed</title>
</head> </head>
<body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
<body bgcolor="#FFFFFF"> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
<a href="index.htm"><IMG height=86 "header">
alt="c++boost.gif (8819 bytes)" <tr>
src="../../../c++boost.gif" <td valign="top" width="300">
width=277 align=center></a> <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Tutorial examples preprocessed</h2>
</td>
</tr>
</table>
<hr> <hr>
<h1>Boost PREPROCESSOR library: Tutorial examples preprocessed</h1>
<p>The following code snippets were produced by actually preprocessing the code <p>The following code snippets were produced by actually preprocessing the code
snippets of the tutorial. After preprocessing the code was reformatted manually.</p> snippets of the tutorial. After preprocessing the code was reformatted manually.</p>
@ -323,12 +329,15 @@ BAD PARAMS FOR SPECIAL_NUMBERED_LIST! E0, E1, E2, S</pre>
</blockquote> </blockquote>
<hr> <hr>
<p><EFBFBD> Copyright Housemarque Oy 2001</p> <p>Revised
<p>Permission to copy, use, modify, sell and distribute this document is granted <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
provided this copyright notice appears in all copies. This document is provided <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
"as is" without express or implied warranty, and with no claim as to its suitability </p>
for any purpose. </p> <p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" -->
<p></p> <p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
"as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body> </body>
</html> </html>

View File

@ -1,64 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<BODY bgcolor="#FFFFFF"> <title>Boost.Preprocessor - Index</title>
</head>
<table border="1" bgcolor="#007F7F" cellpadding="2"> <body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
<tr> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
<td bgcolor="#FFFFFF"><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td> "header">
<td><a href="../../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home </big></font></a></td> <tr>
<td><a href="../../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries </big></font></a></td> <td valign="top" width="300">
<td><a href="../../../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People </big></font></a></td> <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
<td><a href="../../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ </big></font></a></td> </td>
<td><a href="../../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More </big></font></a></td> <td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Index</h2>
</td>
</tr> </tr>
</table> </table>
<h1>Boost PREPROCESSOR library</h1> <hr>
<p>C++ programming sometimes involves repeating lists of template or function <h2>Contents</h2>
parameters. Such repetition is troublesome, because it tends to be done manually, <dl>
which means that the maximum number of parameters is bound into the design of <dt><a href="tutorial.htm">Tutorial</a></dt>
the program making it difficult to configure. Automating the repetition using <dt><a href="reference/index.htm">Reference</a></dt>
extra linguistic tools introduces another set of problems.</p> <dt><a href="known_problems_with_cpp.htm">Widely known problems with the C preprocessor</a></dt>
<p>The C preprocessor is part of the C++ language and can manipulate and generate <dt><a href="keywords.txt">Keywords for syntax highlighting</a></dt>
tokens. Unfortunately the C preprocessor is also a very low level macro processor. <dt><a href="problems_with_compilers.htm">Known problems with specific compilers</a></dt>
In particular, it doesn't directly support repetition or recursion. Fortunately <dt><a href="references.htm">References</a></dt>
it is possible to perform finite repetition and recursion using a library of <dt><a href="acknowledgements.htm">Acknowledgements</a></dt>
preprocessor primitives.</p> </dl>
<p>The PREPROCESSOR library provides facilities for C preprocessor metaprogramming.
Preprocessor metaprogramming makes it possible to generate function and template
parameter lists and make libraries configurable through preprocessor definitions.</p>
<h2>Documentation</h2>
<DL>
<LI><A href="tutorial.htm">Tutorial</A>
<LI><A href="reference/index.htm">Reference</A>
<LI><a href="known_problems_with_cpp.htm">Widely known problems with the C preprocessor</a>
<LI><A href="keywords.txt">Keywords for syntax highlighting</A>
<LI><A href="references.htm">References</A>
<LI><A href="problems_with_compilers.htm">Known problems with specific compilers</A>
</DL>
<h3>Acknowledgements</h3>
<p>The original idea of passing two extra parameters to REPEAT, which makes it
possible to create preprocessor code on top of it, was due to Aleksey Gurtovoy.
The invokeable IDENTITY macro was also invented by him. He also suggested the
name for the library. Many thanks to Aleksey for his insights!</p>
<p>Thanks to everyone who participated in the review: David Abrahams, Beman Dawes,
Ronald Garcia, Douglas Gregor, Aleksey Gurtovoy, Jeremy Siek, and Daryle Walker.</p>
<p>Thanks to Chris Little and Mat Marcus for providing help with MWCW.</p>
<p>The PREPROCESSOR library has been developed by
<a href="../../../people/vesa_karvonen.htm">Vesa Karvonen</a>.</p>
<hr> <hr>
<p><EFBFBD> Copyright Housemarque Oy 2001</p> <p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided <p><i>Permission to copy, use, modify, sell and distribute this document is granted
"as is" without express or implied warranty, and with no claim as to its suitability provided this copyright notice appears in all copies. This document is provided
for any purpose. </p> "as is" without express or implied warranty, and with no claim as to its suitability
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->30 Nov 2001<!--webbot bot="Timestamp" i-checksum="15239" endspan --> for any purpose.</i></p>
<p></p> </body>
</html>
</BODY></HTML>

View File

@ -1,17 +1,25 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE> <head>
<BODY bgcolor="#ffffff"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<a href="index.htm"><IMG height=86 <title>Boost.Preprocessor - Widely known problems with the C preprocessor</title>
alt="c++boost.gif (8819 bytes)" </head>
src="../../../c++boost.gif" <body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
width=277 align=center></a> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Widely known problems with the C preprocessor</h2>
</td>
</tr>
</table>
<hr> <hr>
<h1>Boost PREPROCESSOR library:&nbsp;Widely known problems with the C preprocessor</h1> <p>Preprocessor metaprogramming is subject to heated discussions. Part of this is caused by
<p>
Preprocessor metaprogramming is subject to heated discussions. Part of this is caused by
bad experiences with dangerous techniques, such as defining inline functions using macros. As a rule bad experiences with dangerous techniques, such as defining inline functions using macros. As a rule
of thumb, if you can find a clean and of thumb, if you can find a clean and
manageable way to do something without using the preprocessor, then manageable way to do something without using the preprocessor, then
@ -102,12 +110,15 @@ long time.</P>
<P><EM><B>In practice, preprocessor metaprogramming is far simpler and more portable <P><EM><B>In practice, preprocessor metaprogramming is far simpler and more portable
than template metaprogramming <A href="references.htm#[2]">[2]</A>.</B></EM></P> than template metaprogramming <A href="references.htm#[2]">[2]</A>.</B></EM></P>
<hr> <hr>
<P><EFBFBD> Copyright Housemarque Oy 2001</P> <p>Revised
<p>Permission to copy, use, modify, sell and distribute this document is granted <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
provided this copyright notice appears in all copies. This document is provided <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
"as is" without express or implied warranty, and with no claim as to its suitability </p>
for any purpose. </p> <p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
<p></p> <p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
</BODY></HTML> "as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body>
</html>

View File

@ -1,13 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE> <head>
<BODY bgcolor="#ffffff"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<a href="index.htm"><IMG height=86 <title>Boost.Preprocessor - Known problems with specific compilers</title>
alt="c++boost.gif (8819 bytes)" </head>
src="../../../c++boost.gif" <body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
width=277 align=center></a> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
<hr> "header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Known problems with specific compilers</h2>
</td>
</tr>
</table>
<h1>Boost PREPROCESSOR library:&nbsp;Known problems with specific compilers</h1> <hr>
<p> Some compilers have buggy or limited preprocessors. This page explains known <p> Some compilers have buggy or limited preprocessors. This page explains known
problems with specific compilers.</p> problems with specific compilers.</p>
@ -115,12 +125,15 @@ BOOST_PP_REPEAT_2ND(BOOST_PP_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER
<p align="right"><i>Reported by Aleksey Gurtovoy</i></p> <p align="right"><i>Reported by Aleksey Gurtovoy</i></p>
<hr> <hr>
<P><EFBFBD> Copyright Housemarque Oy 2001</P> <p>Revised
<p>Permission to copy, use, modify, sell and distribute this document is granted <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
provided this copyright notice appears in all copies. This document is provided <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
"as is" without express or implied warranty, and with no claim as to its suitability </p>
for any purpose. </p> <p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
<p></p> <p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
</BODY></HTML> "as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body>
</html>

View File

@ -45,7 +45,7 @@
<h3>Uses</h3> <h3>Uses</h3>
<ul> <ul>
<li><a href="list_for_each.htm#BOOST_PP_LIST_FOR_EACH">BOOST_PP_LIST_FOR_EACH</a>()</li> <li><a href="for.htm#BOOST_PP_FOR">BOOST_PP_FOR</a>()</li>
</ul> </ul>
<hr> <hr>

View File

@ -1,13 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE> <head>
<BODY bgcolor="#FFFFFF"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<a href="index.htm"><IMG height=86 <title>Boost.Preprocessor - References</title>
alt="c++boost.gif (8819 bytes)" </head>
src="../../../c++boost.gif" <body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
width=277 align=center></a> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
<hr> "header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">References</h2>
</td>
</tr>
</table>
<h1>Boost PREPROCESSOR library: References</h1> <hr>
<OL> <OL>
<LI> <a name="[1]">Stroustrup: The Design and Evolution of C++, ISBN 0-201-54330-3</a> <LI> <a name="[1]">Stroustrup: The Design and Evolution of C++, ISBN 0-201-54330-3</a>
@ -20,16 +30,11 @@
<hr> <hr>
<P></P> <p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p><EFBFBD> Copyright Housemarque Oy 2001</p> <p><i>Permission to copy, use, modify, sell and distribute this document is granted
<p>Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided
provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability
"as is" without express or implied warranty, and with no claim as to its suitability for any purpose.</i></p>
for any purpose. </p> </body>
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --> </html>
</p>
<p></p>
</BODY></HTML>

View File

@ -1,36 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE> <head>
<BODY bgcolor="#FFFFFF"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<a href="index.htm"><IMG height=86 <title>Boost.Preprocessor - Tutorial</title>
alt="c++boost.gif (8819 bytes)" </head>
src="../../../c++boost.gif" <body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
width=277 align=center></a> <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Tutorial</h2>
</td>
</tr>
</table>
<hr> <hr>
<h1>Boost PREPROCESSOR library: Tutorial</h1>
<hr>
<h2>Contents</h2> <h2>Contents</h2>
<ul> <dl>
<li><a href="#Motivation">Motivation</a></li> <dt><a href="#Motivation">Motivation</a></dt>
<li><a href="#Techniques">Preprocessor Metaprogramming Techniques</a> <dt><a href="#Techniques">Preprocessor Metaprogramming Techniques</a>
<ul> <dl>
<li><a href="#Local Macro">Use a Local Macro to avoid small scale repetition</a></li> <dt><a href="#Local Macro">Use a Local Macro to avoid small scale repetition</a></dt>
<li><a href="#UNUSED">Use BOOST_PP_EMPTY as an unused parameter in Local <dt><a href="#UNUSED">Use BOOST_PP_EMPTY as an unused parameter in Local
Macro instantiations</a></li> Macro instantiations</a></dt>
<li><a href="#CAT">Use BOOST_PP_CAT instead of ## when necessary</a></li> <dt><a href="#CAT">Use BOOST_PP_CAT instead of ## when necessary</a></dt>
<li><a href="#STRINGIZE">Use BOOST_PP_STRINGIZE instead of # whenever necessary</a></li> <dt><a href="#STRINGIZE">Use BOOST_PP_STRINGIZE instead of # whenever necessary</a></dt>
<li><a href="#ENUM_PARAMS">Avoid O(N) repetition on lists in general</a></li> <dt><a href="#ENUM_PARAMS">Avoid O(N) repetition on lists in general</a></dt>
<li><a href="#Conditional Define">Use a Conditional Define to enable user configuration of code repetition</a></li> <dt><a href="#Conditional Define">Use a Conditional Define to enable user configuration of code repetition</a></dt>
<li><a href="#Token Look-Up">Use Token Look-Up Function to eliminate categorical repetition</a></li> <dt><a href="#Token Look-Up">Use Token Look-Up Function to eliminate categorical repetition</a></dt>
<li><a href="#2ND_REPEAT">Use BOOST_PP_REPEAT_2ND to avoid O(N*N) repetition</a></li> <dt><a href="#2ND_REPEAT">Use BOOST_PP_REPEAT_2ND to avoid O(N*N) repetition</a></dt>
<li><a href="#IF">Use BOOST_PP_IF to implement special case for the first element</a> <dt><a href="#IF">Use BOOST_PP_IF to implement special case for the first element</a></dt>
<li><a href="#Arithmetic">Use arithmetic, logical and comparison operations when necessary</a> <dt><a href="#Arithmetic">Use arithmetic, logical and comparison operations when necessary</a></dt>
</li> </dl>
</ul> </dt>
</li> </dl>
</ul>
<hr> <hr>
<h2><a name="Motivation">Motivation</a></h2> <h2><a name="Motivation">Motivation</a></h2>
<p>The C++ function and template parameter lists are special syntactic constructs <p>The C++ function and template parameter lists are special syntactic constructs
and it is impossible to directly manipulate or generate them using C++ constructs. and it is impossible to directly manipulate or generate them using C++ constructs.
This leads to unnecessary code repetition.</p> This leads to unnecessary code repetition.</p>
@ -475,14 +486,15 @@ SPECIAL_NUMBERED_LIST(3,3,E,S)
</blockquote> </blockquote>
<hr> <hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<P></P> <p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
<p><EFBFBD> Copyright Housemarque Oy 2001</p> "as is" without express or implied warranty, and with no claim as to its suitability
<p>Permission to copy, use, modify, sell and distribute this document is granted for any purpose.</i></p>
provided this copyright notice appears in all copies. This document is provided </body>
"as is" without express or implied warranty, and with no claim as to its suitability </html>
for any purpose. </p>
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
</BODY></HTML>