Tech Talk About C++ Templates
Comeau C++ Template FAQ

Copyright © 2000-2013 Comeau Computing. All rights reserved.

Note that this is a live web page, in the sense that we'll be adding new discussions as appropriate, so stop by from time to time. This web page is evolving (Version 1.7, July, 2013), so if you see something not right, or have a question that is appropriate (note this FAQ is not a templates tutorial) please email us about it.

The intent of this page is to address questions about C++ templates. It is a spin off of http://www.comeaucomputing.com/techtalk, which discusses some general C++ and C issues. You may also want to check out http://www.comeaucomputing.com/techtalk/c99, which discusses some aspects of C99, the latest revision of Standard C. This page addresses templates issues that come up often, perhaps too often. However, it is exactly the frequency of these topics that is the reason for including a discussion of them below. These issues usually come up as having originated from a misleading statement commonly made, or from code shown in a book. These points have found themselves here as the result of our connection to the C++ and C communities for 20 years, whether teaching, helping in newsgroups, providing tech support for Comeau C++, or just plain listening to folks' issues. Some of the topics below may be found in other FAQs. In the Comeau FAQs we do not just regurgitate the same info but try to offer more information on the respective topics, as well as issues related to them. As mentioned, we expect further expansion of some of the topics below, in addition to adding new topics. Here's the current topics:

  1. What book do you recommend?
  2. Where is the FAQ for the various C and C++ newsgroups?
  3. What is the difference between a template class and a class template?
  4. What is the difference between a template function and a function template?
  5. What's the export keyword about?
  6. Why do I get a link error when compiling my templates?
  7. What's wrong with saying vector&