Topic: Explicit template instanciation problem


Author: kuehl@horn.fmi.uni-konstanz.de (Dietmar Kuehl)
Date: 1999/05/01
Raw View
Hi,
Miniussi (miniussi@ilog.fr) wrote:
: I would like to know if there is a way to group these
: explicit instanciations so that:

: template instanciate_al_the_set_stuff etc....

: whould generate all the needed instanciation ?


Sure: Just define the auxiliary classes as subclasses of the main
class. These will then get instantiated at the same time when the
main class is instantiated:

  template <typename T>
  class my_container
  {
  public:
    class iterator;
    // more stuff...
  };

  template <typename T>
  class my_container::iterator
  {
    // class definition; it may also be defined in the body of
    // my_container. This is necessary with some current compilers
  };

  template class my_container<my_type>;

This would instantiate all members not instantiated prior to this
statement, including class members.
--
<mailto:dietmar.kuehl@claas-solutions.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]