summaryrefslogtreecommitdiff
path: root/docs/tutorials/templates.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/templates.html')
-rw-r--r--docs/tutorials/templates.html185
1 files changed, 0 insertions, 185 deletions
diff --git a/docs/tutorials/templates.html b/docs/tutorials/templates.html
deleted file mode 100644
index 81294f489b0..00000000000
--- a/docs/tutorials/templates.html
+++ /dev/null
@@ -1,185 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
- <head>
- <title>About C++ Templates</title>
- </head>
-
- <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-<center>
- <h1>About C++ Templates</h1>
-</center>
-
-
- <hr>
-
-When you get to server.cpp in Tutorial 2 you'll see these lines at the bottom:
-<P>
-<UL>
-<PRE>
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR>;
-template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR>
-#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
-#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-<font size=-1>Thanks to Krishna Padmasola for providing these.</font>
-</PRE>
-</UL>
-<P>
-What's that all about?
-<P>
-Well, if you've been doing ACE for more than about 30 seconds you will
-have run into the joys and sorrows of C++ templates. They're really
-great things that prevent the need for complex #define'd macros,
-ensure type safety and do other really nifty things. One of the
-problems, however, is that not all compilers can figure out what
-templates you need.
-<P>
-Take the simple templated class:
-<UL>
-<PRE>
-template <class DATATYPE>
-class MyTemplate
-{
-public:
- MyTemplate(void)
- {
- }
-
- DATATYPE data(void)
- {
- return data_;
- }
-
- void data( DATATYE _data )
- {
- data_ = _data;
- }
-
-protected:
-
- DATATYPE data_;
-};
-</PRE>
-</UL>
-<P>
-Now suppose you write the following code fragment:
-<P>
-<UL>
-<PRE>
-int main(int,char**)
-{
- MyTemplate<int> itemp;
- MyTemplate<char> ctemp;
-
- ...
-}
-</pre>
-</ul>
-<P>
-Some compilers will take care of you and automatically generate the
-equivalent classes:
-<UL>
-<pre>
-class MyTemplate
-{
-public:
- MyTemplate(void)
- {
- }
-
- int data(void)
- {
- return data_;
- }
-
- void data( int _data )
- {
- data_ = _data;
- }
-
-protected:
-
- int data_;
-};
-
-class MyTemplate
-{
-public:
- MyTemplate(void)
- {
- }
-
- char data(void)
- {
- return data_;
- }
-
- void data( char _data )
- {
- data_ = _data;
- }
-
-protected:
-
- char data_;
-};
-</pre>
-</ul>
-<P>
-On the other hand, some compilers will complain loudly about undefined
-symbols and all sorts of other things. When Clinton Carr compiled
-server.cpp of Tutorial 2 on his RedHat 5.1 (gcc) system, for instance,
-he was rewarded with these lovely errors:
-<P>
-<UL>
-<PRE>
-server.cpp:60: undefined reference to `ACE_Acceptor<Client_Handler, ACE_SOCK_Acceptor>::ACE_Acceptor(ACE_Reactor *)'
-server.cpp:72: undefined reference to `ACE_Acceptor<Client_Handler, ACE_SOCK_Acceptor>::open(ACE_INET_Addr const &, ACE_Reactor *,int)'
-server.cpp:73: undefined reference to `ACE_Acceptor<Client_Handler, ACE_SOCK_Acceptor>::~ACE_Acceptor(void)'
-server.cpp:112: undefined reference to `ACE_Acceptor<Client_Handler, ACE_SOCK_Acceptor>::~ACE_Acceptor(void)'
-</PRE>
-</UL>
-<P>
-Figuring out the correct manual instantiations is usually an
-interative and tedious process. On Linux, I generally use a version of gcc that
-will do automatic instantiaion. "Normal" gcc with the Cygnus repo
-patches does that as does egcs. Lately (9/98) I've been using egcs
-1.1b with pretty good results. On our Digital Unix 4.0b system the
-native compiler (CXX) has switches that will request it to also
-automatically instantiate templates as needed.
-<P>
-The tradeoffs?
-<P>
-If you choose to do manual instantiation then your code will work just
-about anywhere ACE will. For complex applications, it can take a
-number of hours to get things right.
-<P>
-If you choose to let the compiler do instantiations for you then it
-will perform the iterative process. That means that every compile
-will be longer than without manual instantiations.
-<P>
-Compromise?
-<P>
-Yes, you can do that. You can manually instantiate some
-templates and let the compiler get the rest. Some compilers will
-generate output that you can then use to figure out the correct
-templates. Gcc/egcs create .rpo files for each object. These files
-contain mangled names that the compiler uses to figure out what to
-instantiate. With c++filt and some patience, you can parse that stuff
-to figure out what the compiler is instantiating for you.
-<P>
-My best advice is to get a compiler that will handle the
-instantiations for you. When you have some free time on your hands,
-take a look at it's intermediate files (if any) and start working on
-manual instantiation.
-<P>
-For some more hints, take a look at <A HREF="../../ACE-INSTALL.html#g++">ACE-INSTALL</A>
-<P>
- <hr>
-
-
- </body>
-</html>
- \ No newline at end of file